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
c7c71c94
Commit
c7c71c94
authored
Mar 10, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Plain Diff
Merge
--HG-- branch : visible-grades
parents
cde9ab28
a2c4010b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
1 deletions
+59
-1
courseware/content_parser.py
+7
-1
settings.py
+1
-0
student/models.py
+51
-0
No files found.
courseware/content_parser.py
View file @
c7c71c94
...
...
@@ -151,7 +151,13 @@ def user_groups(user):
# TODO: Rewrite in Django
key
=
'user_group_names_{user.id}'
.
format
(
user
=
user
)
cache_expiration
=
60
*
60
# one hour
group_names
=
cache
.
get
(
fasthash
(
key
))
# Kill caching on dev machines -- we switch groups a lot
if
"dev"
not
in
setting
.
DEFAULT_GROUPS
:
group_names
=
cache
.
get
(
fasthash
(
key
))
else
:
group_names
=
None
if
group_names
is
None
:
group_names
=
[
u
.
name
for
u
in
UserTestGroup
.
objects
.
filter
(
users
=
user
)]
cache
.
set
(
fasthash
(
key
),
group_names
,
cache_expiration
)
...
...
settings.py
View file @
c7c71c94
...
...
@@ -6,6 +6,7 @@ import tempfile
import
djcelery
# from settings2.askbotsettings import LIVESETTINGS_OPTIONS
DEFAULT_GROUPS
=
[]
# Configuration option for when we want to grab server error pages
STATIC_GRAB
=
False
...
...
student/models.py
View file @
c7c71c94
...
...
@@ -29,6 +29,8 @@ class UserProfile(models.Model):
meta
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
)
# JSON dictionary for future expansion
courseware
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
default
=
'course.xml'
)
## TODO: Should be renamed to generic UserGroup, and possibly
# Given an optional field for type of group
class
UserTestGroup
(
models
.
Model
):
users
=
models
.
ManyToManyField
(
User
,
db_index
=
True
)
name
=
models
.
CharField
(
blank
=
False
,
max_length
=
32
,
db_index
=
True
)
...
...
@@ -57,3 +59,52 @@ class Registration(models.Model):
#self.delete()
#cache_relation(User.profile)
#### Helper methods for use from python manage.py shell.
def
get_user
(
email
):
u
=
User
.
objects
.
get
(
email
=
email
)
up
=
UserProfile
.
objects
.
get
(
user
=
u
)
return
u
,
up
def
user_info
(
email
):
u
,
up
=
get_user
(
email
)
print
"User id"
,
u
.
id
print
"Username"
,
u
.
username
print
"E-mail"
,
u
.
email
print
"Name"
,
up
.
name
print
"Location"
,
up
.
location
print
"Language"
,
up
.
language
return
u
,
up
def
change_email
(
old_email
,
new_email
):
u
=
User
.
objects
.
get
(
email
=
old_email
)
u
.
email
=
new_email
u
.
save
()
def
change_name
(
email
,
new_name
):
u
,
up
=
get_user
(
email
)
up
.
name
=
new_name
up
.
save
()
def
user_count
():
return
User
.
objects
.
all
()
.
count
()
def
active_user_count
():
return
User
.
objects
.
filter
(
is_active
=
True
)
.
count
()
def
create_group
(
name
,
description
):
utg
=
UserTestGroup
()
utg
.
name
=
name
utg
.
description
=
description
utg
.
save
()
def
add_user_to_group
(
group
,
user
):
utg
=
UserTestGroup
.
objects
.
get
(
name
=
group
)
utg
.
users
.
add
(
User
.
objects
.
get
(
username
=
user
))
utg
.
save
()
def
remove_user_from_group
(
group
,
user
):
utg
=
UserTestGroup
.
objects
.
get
(
name
=
group
)
utg
.
users
.
add
(
User
.
objects
.
get
(
username
=
user
))
utg
.
save
()
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