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
3ecf35e7
Commit
3ecf35e7
authored
Mar 22, 2018
by
Bessie Steinberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Journal Bundle model
parent
06e0d2f5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
9 deletions
+125
-9
course_discovery/apps/journal/admin.py
+26
-1
course_discovery/apps/journal/migrations/0002_auto_20180322_1823.py
+48
-0
course_discovery/apps/journal/migrations/0003_auto_20180322_1827.py
+24
-0
course_discovery/apps/journal/models.py
+27
-8
No files found.
course_discovery/apps/journal/admin.py
View file @
3ecf35e7
from
django.contrib
import
admin
from
django.contrib
import
admin
from
.models
import
JournalBundle
,
Journal
# Register your models here.
@admin.register
(
Journal
)
class
JournalAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'title'
,
'partner'
,
'uuid'
,
)
raw_id_fields
=
(
'partner'
,
)
@admin.register
(
JournalBundle
)
class
JournalBundleAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'id'
,
'uuid'
,
'title'
)
raw_id_fields
=
(
'journals'
,
'courses'
)
\ No newline at end of file
course_discovery/apps/journal/migrations/0002_auto_20180322_1823.py
0 → 100644
View file @
3ecf35e7
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-03-22 18:23
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'
,
'0079_enable_program_default_true'
),
(
'journal'
,
'0001_initial'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'JournalBundle'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'created'
,
django_extensions
.
db
.
fields
.
CreationDateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'created'
)),
(
'modified'
,
django_extensions
.
db
.
fields
.
ModificationDateTimeField
(
auto_now
=
True
,
verbose_name
=
'modified'
)),
(
'uuid'
,
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
editable
=
False
,
verbose_name
=
'UUID'
)),
(
'title'
,
models
.
CharField
(
help_text
=
'The user-facing display title for this Journal Bundle'
,
max_length
=
255
,
unique
=
True
)),
(
'courses'
,
models
.
ManyToManyField
(
blank
=
True
,
to
=
'course_metadata.Course'
)),
],
options
=
{
'abstract'
:
False
,
'ordering'
:
(
'-modified'
,
'-created'
),
'get_latest_by'
:
'modified'
,
},
),
migrations
.
RemoveField
(
model_name
=
'journal'
,
name
=
'key'
,
),
migrations
.
AlterField
(
model_name
=
'journal'
,
name
=
'title'
,
field
=
models
.
CharField
(
blank
=
True
,
default
=
None
,
max_length
=
255
,
null
=
True
),
),
migrations
.
AddField
(
model_name
=
'journalbundle'
,
name
=
'journals'
,
field
=
models
.
ManyToManyField
(
blank
=
True
,
to
=
'journal.Journal'
),
),
]
course_discovery/apps/journal/migrations/0003_auto_20180322_1827.py
0 → 100644
View file @
3ecf35e7
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-03-22 18:27
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0007_auto_20171004_1133'
),
(
'journal'
,
'0002_auto_20180322_1823'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'journal'
,
options
=
{},
),
migrations
.
AlterUniqueTogether
(
name
=
'journal'
,
unique_together
=
set
([(
'partner'
,
'uuid'
)]),
),
]
course_discovery/apps/journal/models.py
View file @
3ecf35e7
from
django.db
import
models
from
django.db
import
models
from
django_extensions.db.models
import
TimeStampedModel
from
django_extensions.db.models
import
TimeStampedModel
from
django.utils.translation
import
ugettext_lazy
as
_
from
uuid
import
uuid4
from
uuid
import
uuid4
from
course_discovery.apps.core.models
import
Currency
,
Partner
from
course_discovery.apps.core.models
import
Currency
,
Partner
from
course_discovery.apps.course_metadata.models
import
Course
CHARFIELD_MAX_LENGTH
=
255
class
Journal
(
TimeStampedModel
):
class
Journal
(
TimeStampedModel
):
"""" Journal model """
"""" Journal model """
...
@@ -16,12 +19,11 @@ class Journal(TimeStampedModel):
...
@@ -16,12 +19,11 @@ class Journal(TimeStampedModel):
uuid
=
models
.
UUIDField
(
uuid
=
models
.
UUIDField
(
default
=
uuid4
,
default
=
uuid4
,
editable
=
False
,
editable
=
False
,
verbose_name
=
'UUID'
,
verbose_name
=
_
(
'UUID'
)
,
)
)
partner
=
models
.
ForeignKey
(
Partner
)
partner
=
models
.
ForeignKey
(
Partner
)
key
=
models
.
CharField
(
max_length
=
255
)
title
=
models
.
CharField
(
title
=
models
.
CharField
(
max_length
=
225
,
max_length
=
CHARFIELD_MAX_LENGTH
,
default
=
None
,
default
=
None
,
null
=
True
,
null
=
True
,
blank
=
True
blank
=
True
...
@@ -31,8 +33,26 @@ class Journal(TimeStampedModel):
...
@@ -31,8 +33,26 @@ class Journal(TimeStampedModel):
sku
=
models
.
CharField
(
max_length
=
128
,
null
=
True
,
blank
=
True
)
sku
=
models
.
CharField
(
max_length
=
128
,
null
=
True
,
blank
=
True
)
expires
=
models
.
DateTimeField
(
null
=
True
,
blank
=
True
)
expires
=
models
.
DateTimeField
(
null
=
True
,
blank
=
True
)
class
Meta
:
unique_together
=
(
(
'partner'
,
'uuid'
),
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'{key}: {title}'
.
format
(
return
self
.
title
key
=
self
.
key
,
title
=
self
.
title
)
class
JournalBundle
(
TimeStampedModel
):
\ No newline at end of file
""" Journal Bundle Model """
uuid
=
models
.
UUIDField
(
default
=
uuid4
,
editable
=
False
,
verbose_name
=
_
(
'UUID'
)
)
title
=
models
.
CharField
(
help_text
=
_
(
'The user-facing display title for this Journal Bundle'
),
max_length
=
CHARFIELD_MAX_LENGTH
,
unique
=
True
)
journals
=
models
.
ManyToManyField
(
Journal
,
blank
=
True
)
courses
=
models
.
ManyToManyField
(
Course
,
blank
=
True
)
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