Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
75c5c1ce
Commit
75c5c1ce
authored
13 years ago
by
Piotr Mitros
Browse files
Options
Downloads
Patches
Plain Diff
Name changes work, but meta storage not tested
parent
2b173379
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
djangoapps/student/views.py
+40
-15
40 additions, 15 deletions
djangoapps/student/views.py
templates/name_changes.html
+31
-1
31 additions, 1 deletion
templates/name_changes.html
templates/profile.html
+5
-4
5 additions, 4 deletions
templates/profile.html
urls.py
+4
-0
4 additions, 0 deletions
urls.py
with
80 additions
and
20 deletions
djangoapps/student/views.py
+
40
−
15
View file @
75c5c1ce
...
...
@@ -383,8 +383,11 @@ def change_name_request(request):
if
not
request
.
user
.
is_authenticated
:
raise
Http404
pnc
=
PendingNameChange
()
pnc
.
user
=
request
.
User
try
:
pnc
=
PendingNameChange
.
objects
.
get
(
user
=
request
.
user
)
except
:
pnc
=
PendingNameChange
()
pnc
.
user
=
request
.
user
pnc
.
new_name
=
request
.
POST
[
'
new_name
'
]
pnc
.
rationale
=
request
.
POST
[
'
rationale
'
]
if
len
(
pnc
.
new_name
)
<
2
:
...
...
@@ -395,37 +398,59 @@ def change_name_request(request):
return
HttpResponse
(
json
.
dumps
({
'
success
'
:
True
}))
@ensure_csrf_cookie
def
change_name_list
(
request
):
def
pending_name_changes
(
request
):
print
request
.
user
.
is_staff
,
request
.
user
if
not
request
.
user
.
is_staff
:
print
"
AAAA
"
raise
Http404
changes
=
list
(
PendingNameChange
.
objects
.
all
())
json
=
[{
'
new_name
'
:
c
.
new_name
,
'
rationale
'
:
c
.
rationale
,
'
old_name
'
:
UserProfile
.
Objects
.
get
(
username
=
c
.
user
).
name
,
'
email
'
:
c
.
user
.
email
,
'
id
'
:
c
.
id
}
for
c
in
changes
]
return
render_to_response
(
'
name_changes.html
'
,
json
)
js
=
{
'
students
'
:
[{
'
new_name
'
:
c
.
new_name
,
'
rationale
'
:
c
.
rationale
,
'
old_name
'
:
UserProfile
.
objects
.
get
(
user
=
c
.
user
).
name
,
'
email
'
:
c
.
user
.
email
,
'
uid
'
:
c
.
user
.
id
,
'
cid
'
:
c
.
id
}
for
c
in
changes
]}
return
render_to_response
(
'
name_changes.html
'
,
js
)
@ensure_csrf_cookie
def
change_name_reject
(
request
):
def
reject_name_change
(
request
):
'''
Course staff clicks
'
reject
'
on a given name change
'''
if
not
request
.
user
.
is_staff
:
raise
Http404
pnc
=
PendingNameChange
.
objects
.
get
(
id
=
int
(
request
.
POST
[
'
id
'
]))
try
:
pnc
=
PendingNameChange
.
objects
.
get
(
id
=
int
(
request
.
POST
[
'
id
'
]))
except
:
return
HttpResponse
(
json
.
dumps
({
'
success
'
:
False
,
'
error
'
:
'
Invalid ID
'
}))
pnc
.
delete
()
return
HttpResponse
(
json
.
dumps
({
'
success
'
:
True
}))
@ensure_csrf_cookie
def
change_name_accept
(
request
):
def
accept_name_change
(
request
):
'''
Course staff clicks
'
accept
'
on a given name change
'''
pnc
=
PendingNameChange
.
objects
.
get
(
id
=
int
(
request
.
POST
[
'
id
'
]))
if
not
request
.
user
.
is_staff
:
raise
Http404
try
:
pnc
=
PendingNameChange
.
objects
.
get
(
id
=
int
(
request
.
POST
[
'
id
'
]))
except
:
return
HttpResponse
(
json
.
dumps
({
'
success
'
:
False
,
'
error
'
:
'
Invalid ID
'
}))
u
=
pnc
.
user
up
=
UserProfile
.
objects
.
get
(
user
=
u
)
up
.
name
=
pnc
.
name
# Save old name
meta
=
up
.
get_meta
()
print
meta
if
'
old_names
'
not
in
meta
:
meta
[
'
old_names
'
]
=
[]
meta
[
'
old_names
'
].
append
(
up
.
name
)
up
.
set_meta
(
meta
)
up
.
name
=
pnc
.
new_name
up
.
save
()
pnc
.
delete
()
return
HttpResponse
(
json
.
dumps
({
'
success
'
:
True
}))
return
HttpResponse
(
json
.
dumps
({
'
success
'
:
True
}))
This diff is collapsed.
Click to expand it.
templates/name_changes.html
+
31
−
1
View file @
75c5c1ce
<
%
inherit
file=
"main.html"
/>
<
%
include
file=
"navigation.html"
args=
"active_page=''"
/>
<section
class=
"main-content"
>
<script>
function
name_confirm
(
id
)
{
postJSON
(
'
/accept_name_change
'
,{
"
id
"
:
id
},
function
(
data
){
if
(
data
.
success
){
$
(
"
#div
"
+
id
).
html
(
"
Accepted
"
);
}
else
{
alert
(
'
Error
'
);
}
});
}
function
name_deny
(
id
)
{
postJSON
(
'
/reject_name_change
'
,{
"
id
"
:
id
},
function
(
data
){
if
(
data
.
success
){
$
(
"
#div
"
+
id
).
html
(
"
Rejected
"
);
}
else
{
alert
(
'
Error
'
);
}
});
}
</script>
<div
class=
"gradebook-wrapper"
>
<section
class=
"gradebook-content"
>
<h1>
Pending name changes
</h1>
<table>
% for s in students:
<tr><td><a
href=
/profile/${s.uid}/
>
${s.oldname}
</td><td>
${s.newname}
</td><td
onclick=
"update({$s.uid});"
>
[Change]
</td></tr>
<tr>
<td><a
href=
/profile/${s['uid']}/
>
${s['old_name']}
</td>
<td>
${s['new_name']|h}
</td>
<td>
${s['email']|h}
</td>
<td>
${s['rationale']|h}
</td>
<td><span
id=
"div${s['cid']}"
><span
onclick=
"name_confirm(${s['cid']});"
>
[Confirm]
</span>
<span
onclick=
"name_deny(${s['cid']});"
>
[Reject]
</span></span></td></tr>
% endfor
</table>
</section>
...
...
This diff is collapsed.
Click to expand it.
templates/profile.html
+
5
−
4
View file @
75c5c1ce
...
...
@@ -102,13 +102,13 @@ $(function() {
var
new_name
=
$
(
'
#new_name_field
'
).
val
();
var
rationale
=
$
(
'
#name_rationale_field
'
).
val
();
postJSON
(
'
/change_
email
'
,{
"
new_name
"
:
new_name
,
postJSON
(
'
/change_
name
'
,{
"
new_name
"
:
new_name
,
"
rationale
"
:
rationale
},
function
(
data
){
if
(
data
.
success
){
$
(
"
#change
_email
"
).
html
(
"
Request submitted. We'll send you an e-mail if we approve the change or need further information.
"
);
$
(
"
#
apply_name_
change
"
).
html
(
"
Request submitted. We'll send you an e-mail if we approve the change or need further information.
"
);
}
else
{
$
(
"
#change
_email
_error
"
).
html
(
data
.
error
);
$
(
"
#
apply_name_
change_error
"
).
html
(
data
.
error
);
}
});
log_event
(
"
profile
"
,
{
"
type
"
:
"
name_change_request
"
,
...
...
@@ -190,7 +190,7 @@ $(function() {
</li>
<li>
E-mail:
<strong>
${email}
</strong>
<a
href=
"#change_email"
rel=
"leanModal"
class=
"edit-email"
>
Edit
</a>
E-mail:
<strong>
${email}
</strong>
<a
href=
"#change_email"
rel=
"leanModal"
class=
"edit-email"
>
Change
</a>
</li>
<li>
Location:
<div
id=
"location_sub"
>
${location}
</div><div
id=
"description"
></div>
<a
href=
"#"
id=
"change_location"
>
Edit
</a>
...
...
@@ -249,6 +249,7 @@ $(function() {
<div
id=
"change_email"
class=
"leanModal_box"
>
<h1>
Change e-mail
</h1>
<div
id=
"apply_name_change_error"
></div>
<form
id=
"change_email_form"
>
<div
id=
"change_email_error"
>
</div>
<fieldset>
...
...
This diff is collapsed.
Click to expand it.
urls.py
+
4
−
0
View file @
75c5c1ce
...
...
@@ -11,6 +11,10 @@ urlpatterns = ('',
url
(
r
'
^$
'
,
'
student.views.index
'
),
# Main marketing page, or redirect to courseware
url
(
r
'
^change_email$
'
,
'
student.views.change_email_request
'
),
url
(
r
'
^email_confirm/(?P<key>[^/]*)$
'
,
'
student.views.confirm_email_change
'
),
url
(
r
'
^change_name$
'
,
'
student.views.change_name_request
'
),
url
(
r
'
^accept_name_change$
'
,
'
student.views.accept_name_change
'
),
url
(
r
'
^reject_name_change$
'
,
'
student.views.reject_name_change
'
),
url
(
r
'
^pending_name_changes$
'
,
'
student.views.pending_name_changes
'
),
url
(
r
'
^gradebook$
'
,
'
courseware.views.gradebook
'
),
url
(
r
'
^event$
'
,
'
track.views.user_track
'
),
url
(
r
'
^t/(?P<template>[^/]*)$
'
,
'
static_template_view.views.index
'
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment