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
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
7e51f438
Commit
7e51f438
authored
5 years ago
by
atesker
Committed by
Andytr1
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
EDUCATOR-4903. Move defaults to correct place
EDUCATOR-4903. Move defaults to correct place - cr
parent
d0c3f16c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/teams/models.py
+15
-10
15 additions, 10 deletions
lms/djangoapps/teams/models.py
lms/djangoapps/teams/tests/test_models.py
+34
-1
34 additions, 1 deletion
lms/djangoapps/teams/tests/test_models.py
with
49 additions
and
11 deletions
lms/djangoapps/teams/models.py
+
15
−
10
View file @
7e51f438
...
...
@@ -100,6 +100,10 @@ def handle_activity(user, post, original_author_id=None):
CourseTeamMembership
.
update_last_activity
(
user
,
post
.
commentable_id
)
def
utc_now
():
return
datetime
.
utcnow
().
replace
(
tzinfo
=
pytz
.
utc
)
@python_2_unicode_compatible
class
CourseTeam
(
models
.
Model
):
"""
...
...
@@ -128,15 +132,17 @@ class CourseTeam(models.Model):
discussion_topic_id
=
models
.
SlugField
(
max_length
=
255
,
unique
=
True
)
name
=
models
.
CharField
(
max_length
=
255
,
db_index
=
True
)
course_id
=
CourseKeyField
(
max_length
=
255
,
db_index
=
True
)
topic_id
=
models
.
CharField
(
max_length
=
255
,
db_index
=
True
,
blank
=
True
)
topic_id
=
models
.
CharField
(
default
=
''
,
max_length
=
255
,
db_index
=
True
,
blank
=
True
)
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
description
=
models
.
CharField
(
max_length
=
300
)
country
=
CountryField
(
blank
=
True
)
country
=
CountryField
(
default
=
''
,
blank
=
True
)
language
=
LanguageField
(
default
=
''
,
blank
=
True
,
help_text
=
ugettext_lazy
(
"
Optional language the team uses as ISO 639-1 code.
"
),
)
last_activity_at
=
models
.
DateTimeField
(
db_index
=
True
)
# indexed for ordering
# indexed for ordering
last_activity_at
=
models
.
DateTimeField
(
default
=
utc_now
,
db_index
=
True
)
users
=
models
.
ManyToManyField
(
User
,
db_index
=
True
,
related_name
=
'
teams
'
,
through
=
'
CourseTeamMembership
'
)
team_size
=
models
.
IntegerField
(
default
=
0
,
db_index
=
True
)
# indexed for ordering
...
...
@@ -157,9 +163,9 @@ class CourseTeam(models.Model):
name
,
course_id
,
description
,
topic_id
=
None
,
country
=
None
,
language
=
None
,
topic_id
=
''
,
country
=
''
,
language
=
''
,
organization_protected
=
False
):
"""
Create a complete CourseTeam object.
...
...
@@ -188,11 +194,10 @@ class CourseTeam(models.Model):
discussion_topic_id
=
discussion_topic_id
,
name
=
name
,
course_id
=
course_id
,
topic_id
=
topic_id
if
topic_id
else
''
,
topic_id
=
topic_id
,
description
=
description
,
country
=
country
if
country
else
''
,
language
=
language
if
language
else
''
,
last_activity_at
=
datetime
.
utcnow
().
replace
(
tzinfo
=
pytz
.
utc
),
country
=
country
,
language
=
language
,
organization_protected
=
organization_protected
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/teams/tests/test_models.py
+
34
−
1
View file @
7e51f438
...
...
@@ -11,7 +11,7 @@ from datetime import datetime
import
ddt
import
pytz
import
six
from
mock
import
Mock
from
mock
import
Mock
,
patch
from
opaque_keys.edx.keys
import
CourseKey
from
course_modes.models
import
CourseMode
...
...
@@ -124,6 +124,39 @@ class CourseTeamTest(SharedModuleStoreTestCase):
with
self
.
assertRaises
(
AddToIncompatibleTeamError
):
self
.
masters_team
.
add_user
(
self
.
audit_learner
)
def
test_defaults_with_create
(
self
):
field
=
CourseTeam
.
_meta
.
get_field
(
'
last_activity_at
'
)
default_date
=
datetime
(
1978
,
1
,
1
)
mock_now
=
lambda
:
default_date
with
patch
.
object
(
field
,
'
default
'
,
new
=
mock_now
):
team
=
CourseTeam
.
create
(
name
=
'
foo
'
,
course_id
=
'
sedx/the-course/1
'
,
description
=
'
Import from csv
'
,
topic_id
=
TEAMSET_1_ID
,
organization_protected
=
True
)
self
.
assert_team_default_values
(
default_date
,
team
)
def
test_defaults_with_constructor
(
self
):
field
=
CourseTeam
.
_meta
.
get_field
(
'
last_activity_at
'
)
default_date
=
datetime
(
1978
,
1
,
1
)
mock_now
=
lambda
:
default_date
with
patch
.
object
(
field
,
'
default
'
,
new
=
mock_now
):
team
=
CourseTeam
(
name
=
'
foo
'
,
course_id
=
'
sedx/the-course/1
'
,
description
=
'
Import from csv
'
,
topic_id
=
TEAMSET_1_ID
,
organization_protected
=
True
)
self
.
assert_team_default_values
(
default_date
,
team
)
def
assert_team_default_values
(
self
,
default_date
,
team
):
self
.
assertEqual
(
default_date
,
team
.
last_activity_at
)
self
.
assertEqual
(
''
,
team
.
language
)
self
.
assertEqual
(
''
,
team
.
country
)
@ddt.ddt
class
TeamMembershipTest
(
SharedModuleStoreTestCase
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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