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
e31b77ac
Commit
e31b77ac
authored
Aug 25, 2016
by
Matthew Piatetsky
Committed by
GitHub
Aug 25, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #277 from edx/add_marketing_path
Add marketing url path
parents
adcea606
39b501ef
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
3 deletions
+27
-3
course_discovery/apps/api/serializers.py
+1
-1
course_discovery/apps/api/tests/test_serializers.py
+1
-0
course_discovery/apps/course_metadata/models.py
+7
-0
course_discovery/apps/course_metadata/tests/factories.py
+1
-0
course_discovery/apps/course_metadata/tests/test_models.py
+17
-2
No files found.
course_discovery/apps/api/serializers.py
View file @
e31b77ac
...
@@ -205,7 +205,7 @@ class OrganizationSerializer(TaggitSerializer, serializers.ModelSerializer):
...
@@ -205,7 +205,7 @@ class OrganizationSerializer(TaggitSerializer, serializers.ModelSerializer):
class
Meta
(
object
):
class
Meta
(
object
):
model
=
Organization
model
=
Organization
fields
=
(
'key'
,
'name'
,
'description'
,
'homepage_url'
,
'tags'
,
'logo_image_url'
)
fields
=
(
'key'
,
'name'
,
'description'
,
'homepage_url'
,
'tags'
,
'logo_image_url'
,
'marketing_url'
)
class
CatalogSerializer
(
serializers
.
ModelSerializer
):
class
CatalogSerializer
(
serializers
.
ModelSerializer
):
...
...
course_discovery/apps/api/tests/test_serializers.py
View file @
e31b77ac
...
@@ -495,6 +495,7 @@ class OrganizationSerializerTests(TestCase):
...
@@ -495,6 +495,7 @@ class OrganizationSerializerTests(TestCase):
'homepage_url'
:
organization
.
homepage_url
,
'homepage_url'
:
organization
.
homepage_url
,
'logo_image_url'
:
organization
.
logo_image_url
,
'logo_image_url'
:
organization
.
logo_image_url
,
'tags'
:
[
TAG
],
'tags'
:
[
TAG
],
'marketing_url'
:
organization
.
marketing_url
,
}
}
self
.
assertDictEqual
(
serializer
.
data
,
expected
)
self
.
assertDictEqual
(
serializer
.
data
,
expected
)
...
...
course_discovery/apps/course_metadata/models.py
View file @
e31b77ac
...
@@ -167,6 +167,13 @@ class Organization(TimeStampedModel):
...
@@ -167,6 +167,13 @@ class Organization(TimeStampedModel):
def
__str__
(
self
):
def
__str__
(
self
):
return
'{key}: {name}'
.
format
(
key
=
self
.
key
,
name
=
self
.
name
)
return
'{key}: {name}'
.
format
(
key
=
self
.
key
,
name
=
self
.
name
)
@property
def
marketing_url
(
self
):
if
self
.
marketing_url_path
:
return
urljoin
(
self
.
partner
.
marketing_site_url_root
,
self
.
marketing_url_path
)
return
None
class
Person
(
TimeStampedModel
):
class
Person
(
TimeStampedModel
):
""" Person model. """
""" Person model. """
...
...
course_discovery/apps/course_metadata/tests/factories.py
View file @
e31b77ac
...
@@ -148,6 +148,7 @@ class OrganizationFactory(factory.DjangoModelFactory):
...
@@ -148,6 +148,7 @@ class OrganizationFactory(factory.DjangoModelFactory):
logo_image_url
=
FuzzyURL
()
logo_image_url
=
FuzzyURL
()
banner_image_url
=
FuzzyURL
()
banner_image_url
=
FuzzyURL
()
partner
=
factory
.
SubFactory
(
PartnerFactory
)
partner
=
factory
.
SubFactory
(
PartnerFactory
)
marketing_url_path
=
FuzzyText
()
class
Meta
:
class
Meta
:
model
=
Organization
model
=
Organization
...
...
course_discovery/apps/course_metadata/tests/test_models.py
View file @
e31b77ac
...
@@ -166,10 +166,25 @@ class CourseRunTests(TestCase):
...
@@ -166,10 +166,25 @@ class CourseRunTests(TestCase):
class
OrganizationTests
(
TestCase
):
class
OrganizationTests
(
TestCase
):
""" Tests for the `Organization` model. """
""" Tests for the `Organization` model. """
def
setUp
(
self
):
super
(
OrganizationTests
,
self
)
.
setUp
()
self
.
organization
=
factories
.
OrganizationFactory
()
def
test_str
(
self
):
def
test_str
(
self
):
""" Verify casting an instance to a string returns a string containing the key and name. """
""" Verify casting an instance to a string returns a string containing the key and name. """
organization
=
factories
.
OrganizationFactory
()
self
.
assertEqual
(
str
(
self
.
organization
),
'{key}: {name}'
.
format
(
key
=
self
.
organization
.
key
,
self
.
assertEqual
(
str
(
organization
),
'{key}: {name}'
.
format
(
key
=
organization
.
key
,
name
=
organization
.
name
))
name
=
self
.
organization
.
name
))
def
test_marketing_url
(
self
):
""" Verify the property creates a complete marketing URL. """
expected
=
'{root}/{slug}'
.
format
(
root
=
self
.
organization
.
partner
.
marketing_site_url_root
.
strip
(
'/'
),
slug
=
self
.
organization
.
marketing_url_path
)
self
.
assertEqual
(
self
.
organization
.
marketing_url
,
expected
)
def
test_marketing_url_without_marketing_url_path
(
self
):
""" Verify the property returns None if the Organization has no marketing_url_path set. """
self
.
organization
.
marketing_url_path
=
''
self
.
assertIsNone
(
self
.
organization
.
marketing_url
)
class
PersonTests
(
TestCase
):
class
PersonTests
(
TestCase
):
...
...
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