Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
2d08d669
Commit
2d08d669
authored
May 07, 2015
by
muzaffaryousaf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Learner Profile page tweaks.
TNL-2047
parent
36060f3f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
37 deletions
+67
-37
lms/djangoapps/student_profile/views.py
+23
-4
lms/static/js/student_profile/views/learner_profile_factory.js
+38
-29
lms/static/js/views/fields.js
+4
-2
lms/static/sass/views/_learner-profile.scss
+0
-1
lms/templates/student_profile/learner_profile.html
+2
-1
No files found.
lms/djangoapps/student_profile/views.py
View file @
2d08d669
...
...
@@ -10,6 +10,10 @@ from django.http import HttpResponse
from
django.views.decorators.http
import
require_http_methods
from
edxmako.shortcuts
import
render_to_response
from
openedx.core.djangoapps.user_api.preferences.api
import
get_user_preferences
from
openedx.core.djangoapps.user_api.accounts.api
import
get_account_settings
from
openedx.core.djangoapps.user_api.errors
import
UserNotFound
,
UserNotAuthorized
from
openedx.core.djangoapps.user_api.accounts.serializers
import
PROFILE_IMAGE_KEY_PREFIX
from
student.models
import
User
from
microsite_configuration
import
microsite
...
...
@@ -38,13 +42,17 @@ def learner_profile(request, username):
try
:
return
render_to_response
(
'student_profile/learner_profile.html'
,
learner_profile_context
(
request
.
user
.
username
,
username
,
request
.
user
.
is_staff
)
learner_profile_context
(
request
,
request
.
user
.
username
,
username
,
request
.
user
.
is_staff
)
)
except
UserNotAuthorized
:
return
HttpResponse
(
status
=
403
)
except
UserNotFound
:
return
HttpResponse
(
status
=
404
)
except
ObjectDoesNotExist
:
return
HttpResponse
(
status
=
404
)
def
learner_profile_context
(
logged_in_username
,
profile_username
,
user_is_staff
):
def
learner_profile_context
(
request
,
logged_in_username
,
profile_username
,
user_is_staff
):
"""Context for the learner profile page.
Args:
...
...
@@ -67,6 +75,16 @@ def learner_profile_context(logged_in_username, profile_username, user_is_staff)
)
]
own_profile
=
(
logged_in_username
==
profile_username
)
accounts_data
=
get_account_settings
(
request
.
user
,
profile_username
)
# Account for possibly relative URLs.
for
key
,
value
in
accounts_data
[
'profile_image'
]
.
items
():
if
key
.
startswith
(
PROFILE_IMAGE_KEY_PREFIX
):
accounts_data
[
'profile_image'
][
key
]
=
request
.
build_absolute_uri
(
value
)
preferences_data
=
get_user_preferences
(
profile_user
,
profile_username
)
context
=
{
'data'
:
{
'profile_user_id'
:
profile_user
.
id
,
...
...
@@ -74,17 +92,18 @@ def learner_profile_context(logged_in_username, profile_username, user_is_staff)
'default_visibility'
:
settings
.
ACCOUNT_VISIBILITY_CONFIGURATION
[
'default_visibility'
],
'accounts_api_url'
:
reverse
(
"accounts_api"
,
kwargs
=
{
'username'
:
profile_username
}),
'preferences_api_url'
:
reverse
(
'preferences_api'
,
kwargs
=
{
'username'
:
profile_username
}),
'preferences_data'
:
preferences_data
,
'accounts_data'
:
accounts_data
,
'profile_image_upload_url'
:
reverse
(
'profile_image_upload'
,
kwargs
=
{
'username'
:
profile_username
}),
'profile_image_remove_url'
:
reverse
(
'profile_image_remove'
,
kwargs
=
{
'username'
:
profile_username
}),
'profile_image_max_bytes'
:
settings
.
PROFILE_IMAGE_MAX_BYTES
,
'profile_image_min_bytes'
:
settings
.
PROFILE_IMAGE_MIN_BYTES
,
'account_settings_page_url'
:
reverse
(
'account_settings'
),
'has_preferences_access'
:
(
logged_in_username
==
profile_username
or
user_is_staff
),
'own_profile'
:
(
logged_in_username
==
profile_username
)
,
'own_profile'
:
own_profile
,
'country_options'
:
country_options
,
'language_options'
:
settings
.
ALL_LANGUAGES
,
'platform_name'
:
microsite
.
get_value
(
'platform_name'
,
settings
.
PLATFORM_NAME
),
}
}
return
context
lms/static/js/student_profile/views/learner_profile_factory.js
View file @
2d08d669
...
...
@@ -16,18 +16,19 @@
var
learnerProfileElement
=
$
(
'.wrapper-profile'
);
var
defaultVisibility
=
options
.
default_visibility
;
var
AccountPreferencesModelWithDefaults
=
AccountPreferencesModel
.
extend
({
defaults
:
{
account_privacy
:
defaultVisibility
}
});
var
accountPreferencesModel
=
new
AccountPreferencesModelWithDefaults
();
accountPreferencesModel
.
url
=
options
.
preferences_api_url
;
var
accountPreferencesModel
,
accountSettingsModel
;
var
accountSettingsModel
=
new
AccountSettingsModel
({
'default_public_account_fields'
:
options
.
default_public_account_fields
});
if
(
options
.
own_profile
)
{
accountSettingsModel
=
new
AccountSettingsModel
({
'default_public_account_fields'
:
options
.
default_public_account_fields
});
accountPreferencesModel
=
new
AccountPreferencesModel
({
account_privacy
:
defaultVisibility
});
}
else
{
accountSettingsModel
=
new
AccountSettingsModel
(
options
.
accounts_data
,
{
parse
:
true
});
accountPreferencesModel
=
new
AccountPreferencesModel
(
options
.
preferences_data
);
}
accountSettingsModel
.
url
=
options
.
accounts_api_url
;
accountPreferencesModel
.
url
=
options
.
preferences_api_url
;
var
editable
=
options
.
own_profile
?
'toggle'
:
'never'
;
...
...
@@ -146,26 +147,34 @@
learnerProfileView
.
render
();
};
accountSettingsModel
.
fetch
({
success
:
function
()
{
// Fetch the preferences model if the user has access
if
(
options
.
has_preferences_access
)
{
accountPreferencesModel
.
fetch
({
success
:
function
()
{
if
(
accountSettingsModel
.
get
(
'requires_parental_consent'
))
{
accountPreferencesModel
.
set
(
'account_privacy'
,
'private'
);
}
showLearnerProfileView
();
},
error
:
showLoadingError
});
}
else
{
showLearnerProfileView
();
if
(
options
.
own_profile
)
{
accountSettingsModel
.
fetch
({
success
:
function
()
{
// Fetch the preferences model if the user has access
if
(
options
.
has_preferences_access
)
{
accountPreferencesModel
.
fetch
({
success
:
function
()
{
if
(
accountSettingsModel
.
get
(
'requires_parental_consent'
))
{
accountPreferencesModel
.
set
(
'account_privacy'
,
'private'
);
}
showLearnerProfileView
();
},
error
:
showLoadingError
});
}
else
{
showLearnerProfileView
();
}
},
error
:
showLoadingError
});
}
else
{
if
(
options
.
has_preferences_access
)
{
if
(
accountSettingsModel
.
get
(
'requires_parental_consent'
))
{
accountPreferencesModel
.
set
(
'account_privacy'
,
'private'
);
}
}
,
error
:
showLoadingError
}
);
}
showLearnerProfileView
();
}
return
{
accountSettingsModel
:
accountSettingsModel
,
...
...
lms/static/js/views/fields.js
View file @
2d08d669
...
...
@@ -201,13 +201,15 @@
this
.
$el
.
addClass
(
'mode-edit'
);
},
startEditing
:
function
()
{
startEditing
:
function
(
event
)
{
event
.
preventDefault
();
if
(
this
.
editable
===
'toggle'
&&
this
.
mode
!==
'edit'
)
{
this
.
showEditMode
(
true
);
}
},
finishEditing
:
function
()
{
finishEditing
:
function
(
event
)
{
event
.
preventDefault
();
if
(
this
.
fieldValue
()
!==
this
.
modelValue
())
{
this
.
saveValue
();
}
else
{
...
...
lms/static/sass/views/_learner-profile.scss
View file @
2d08d669
...
...
@@ -218,7 +218,6 @@
.wrapper-profile-section-two
{
width
:
flex-grid
(
8
,
12
);
margin-top
:
(
$baseline
*
1
.5
);
}
.profile-section-two-fields
{
...
...
lms/templates/student_profile/learner_profile.html
View file @
2d08d669
<
%!
import
json
%
>
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%!
from
xmodule
.
modulestore
import
EdxJSONEncoder
%
>
<
%
inherit
file=
"/main.html"
/>
<
%
namespace
name=
'static'
file=
'/static_content.html'
/>
...
...
@@ -38,7 +39,7 @@
<script>
(
function
(
require
)
{
require
([
'js/student_profile/views/learner_profile_factory'
],
function
(
setupLearnerProfile
)
{
var
options
=
$
{
json
.
dumps
(
data
)
};
var
options
=
$
{
json
.
dumps
(
data
,
cls
=
EdxJSONEncoder
)
};
setupLearnerProfile
(
options
);
});
}).
call
(
this
,
require
||
RequireJS
.
require
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment