Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
e890f6c8
Commit
e890f6c8
authored
Jul 08, 2016
by
Bill DeRusha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simple program model
parent
91453d0d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
1 deletions
+106
-1
course_discovery/apps/course_metadata/migrations/0004_program.py
+36
-0
course_discovery/apps/course_metadata/models.py
+46
-0
course_discovery/apps/course_metadata/tests/factories.py
+13
-1
course_discovery/apps/course_metadata/tests/test_models.py
+11
-0
No files found.
course_discovery/apps/course_metadata/migrations/0004_program.py
0 → 100644
View file @
e890f6c8
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django_extensions.db.fields
import
uuid
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'course_metadata'
,
'0003_auto_20160523_1422'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Program'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
primary_key
=
True
,
serialize
=
False
,
auto_created
=
True
)),
(
'created'
,
django_extensions
.
db
.
fields
.
CreationDateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'created'
)),
(
'modified'
,
django_extensions
.
db
.
fields
.
ModificationDateTimeField
(
verbose_name
=
'modified'
,
auto_now
=
True
)),
(
'uuid'
,
models
.
UUIDField
(
unique
=
True
,
default
=
uuid
.
uuid4
,
blank
=
True
,
editable
=
False
)),
(
'name'
,
models
.
CharField
(
max_length
=
255
,
help_text
=
'The user-facing display name for this Program.'
,
unique
=
True
)),
(
'subtitle'
,
models
.
CharField
(
help_text
=
'A brief, descriptive subtitle for the Program.'
,
max_length
=
255
,
blank
=
True
)),
(
'category'
,
models
.
CharField
(
help_text
=
'The category / type of Program.'
,
max_length
=
32
)),
(
'status'
,
models
.
CharField
(
help_text
=
'The lifecycle status of this Program.'
,
max_length
=
24
)),
(
'marketing_slug'
,
models
.
CharField
(
help_text
=
'Slug used to generate links to the marketing site'
,
max_length
=
255
,
blank
=
True
)),
(
'organizations'
,
models
.
ManyToManyField
(
to
=
'course_metadata.Organization'
,
blank
=
True
)),
],
options
=
{
'ordering'
:
(
'-modified'
,
'-created'
),
'abstract'
:
False
,
'get_latest_by'
:
'modified'
,
},
),
]
course_discovery/apps/course_metadata/models.py
View file @
e890f6c8
import
datetime
import
logging
from
uuid
import
uuid4
import
pytz
from
django.db
import
models
...
...
@@ -380,3 +381,48 @@ class CourseOrganization(TimeStampedModel):
unique_together
=
(
(
'course'
,
'organization'
,
'relation_type'
),
)
class
Program
(
TimeStampedModel
):
"""
Representation of a Program.
"""
uuid
=
models
.
UUIDField
(
blank
=
True
,
default
=
uuid4
,
editable
=
False
,
unique
=
True
,
)
name
=
models
.
CharField
(
help_text
=
_
(
'The user-facing display name for this Program.'
),
max_length
=
255
,
unique
=
True
,
)
subtitle
=
models
.
CharField
(
help_text
=
_
(
'A brief, descriptive subtitle for the Program.'
),
max_length
=
255
,
blank
=
True
,
)
category
=
models
.
CharField
(
help_text
=
_
(
'The category / type of Program.'
),
max_length
=
32
,
)
status
=
models
.
CharField
(
help_text
=
_
(
'The lifecycle status of this Program.'
),
max_length
=
24
,
)
marketing_slug
=
models
.
CharField
(
help_text
=
_
(
'Slug used to generate links to the marketing site'
),
blank
=
True
,
max_length
=
255
)
organizations
=
models
.
ManyToManyField
(
Organization
,
blank
=
True
)
def
__str__
(
self
):
return
self
.
name
course_discovery/apps/course_metadata/tests/factories.py
View file @
e890f6c8
...
...
@@ -9,7 +9,7 @@ from pytz import UTC
from
course_discovery.apps.ietf_language_tags.models
import
LanguageTag
from
course_discovery.apps.core.models
import
Currency
from
course_discovery.apps.course_metadata.models
import
(
Course
,
CourseRun
,
Organization
,
Person
,
Image
,
Video
,
Subject
,
Seat
,
Prerequisite
,
LevelType
Course
,
CourseRun
,
Organization
,
Person
,
Image
,
Video
,
Subject
,
Seat
,
Prerequisite
,
LevelType
,
Program
)
...
...
@@ -138,3 +138,15 @@ class PersonFactory(factory.DjangoModelFactory):
class
Meta
:
model
=
Person
class
ProgramFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
(
object
):
model
=
Program
name
=
factory
.
Sequence
(
lambda
n
:
'test-program-{}'
.
format
(
n
))
# pylint: disable=unnecessary-lambda
uuid
=
factory
.
Sequence
(
lambda
n
:
n
)
subtitle
=
'test-subtitle'
category
=
'xseries'
status
=
'unpublished'
marketing_slug
=
factory
.
Sequence
(
lambda
n
:
'test-slug-{}'
.
format
(
n
))
# pylint: disable=unnecessary-lambda
course_discovery/apps/course_metadata/tests/test_models.py
View file @
e890f6c8
...
...
@@ -235,3 +235,14 @@ class AbstractValueModelTests(TestCase):
value
=
'abc'
instance
=
TestAbstractValueModel
(
value
=
value
)
self
.
assertEqual
(
str
(
instance
),
value
)
class
ProgramTests
(
TestCase
):
"""Tests of the Program model."""
def
test_str
(
self
):
"""Verify that a program is properly converted to a str."""
program
=
factories
.
ProgramFactory
()
program_str
=
program
.
name
self
.
assertEqual
(
str
(
program
),
program_str
)
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