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
9aa6718b
Commit
9aa6718b
authored
Feb 02, 2016
by
Zia Fazal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed constraints on MicrositeHistory model to allow Updates on Microsite model
fixed quality violations
parent
4b1a37ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
2 deletions
+75
-2
common/djangoapps/microsite_configuration/migrations/0002_auto_20160202_0228.py
+24
-0
common/djangoapps/microsite_configuration/models.py
+2
-2
common/djangoapps/microsite_configuration/tests/test_admin.py
+49
-0
No files found.
common/djangoapps/microsite_configuration/migrations/0002_auto_20160202_0228.py
0 → 100644
View file @
9aa6718b
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'microsite_configuration'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'micrositehistory'
,
name
=
'key'
,
field
=
models
.
CharField
(
max_length
=
63
,
db_index
=
True
),
),
migrations
.
AlterField
(
model_name
=
'micrositehistory'
,
name
=
'site'
,
field
=
models
.
ForeignKey
(
related_name
=
'microsite_history'
,
to
=
'sites.Site'
),
),
]
common/djangoapps/microsite_configuration/models.py
View file @
9aa6718b
...
...
@@ -63,8 +63,8 @@ class MicrositeHistory(TimeStampedModel):
This is an archive table for Microsites model, so that we can maintain a history of changes. Note that the
key field is no longer unique
"""
site
=
models
.
OneToOneField
(
Site
,
related_name
=
'microsite_history'
)
key
=
models
.
CharField
(
max_length
=
63
,
db_index
=
True
,
unique
=
True
)
site
=
models
.
ForeignKey
(
Site
,
related_name
=
'microsite_history'
)
key
=
models
.
CharField
(
max_length
=
63
,
db_index
=
True
)
values
=
JSONField
(
null
=
False
,
blank
=
True
,
load_kwargs
=
{
'object_pairs_hook'
:
collections
.
OrderedDict
})
def
__unicode__
(
self
):
...
...
common/djangoapps/microsite_configuration/tests/test_admin.py
0 → 100644
View file @
9aa6718b
"""
Tests for microsite admin
"""
from
django.contrib.admin.sites
import
AdminSite
from
django.http
import
HttpRequest
from
microsite_configuration.admin
import
MicrositeAdmin
from
microsite_configuration.models
import
Microsite
from
microsite_configuration.tests.tests
import
DatabaseMicrositeTestCase
class
MicrositeAdminTests
(
DatabaseMicrositeTestCase
):
"""
Test class for MicrositeAdmin
"""
def
setUp
(
self
):
super
(
MicrositeAdminTests
,
self
)
.
setUp
()
self
.
adminsite
=
AdminSite
()
self
.
microsite_admin
=
MicrositeAdmin
(
Microsite
,
self
.
adminsite
)
self
.
request
=
HttpRequest
()
def
test_fields_in_admin_form
(
self
):
"""
Tests presence of form fields for Microsite.
"""
microsite_form
=
self
.
microsite_admin
.
get_form
(
self
.
request
,
self
.
microsite
)
self
.
assertEqual
(
list
(
microsite_form
.
base_fields
),
[
"site"
,
"key"
,
"values"
]
)
def
test_save_action_admin_form
(
self
):
"""
Tests save action for Microsite model form.
"""
new_values
=
{
"domain_prefix"
:
"testmicrosite_new"
,
"platform_name"
:
"Test Microsite New"
}
microsite_form
=
self
.
microsite_admin
.
get_form
(
self
.
request
)(
instance
=
self
.
microsite
,
data
=
{
"key"
:
self
.
microsite
.
key
,
"site"
:
self
.
microsite
.
site
.
id
,
"values"
:
new_values
,
})
self
.
assertTrue
(
microsite_form
.
is_valid
())
microsite_form
.
save
()
new_microsite
=
Microsite
.
objects
.
get
(
key
=
self
.
microsite
.
key
)
self
.
assertEqual
(
new_microsite
.
values
,
new_values
)
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