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
ba11ed8c
Commit
ba11ed8c
authored
Aug 25, 2016
by
Matthew Piatetsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add marketing url path
parent
bfae6ac0
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 @
ba11ed8c
...
...
@@ -205,7 +205,7 @@ class OrganizationSerializer(TaggitSerializer, serializers.ModelSerializer):
class
Meta
(
object
):
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
):
...
...
course_discovery/apps/api/tests/test_serializers.py
View file @
ba11ed8c
...
...
@@ -495,6 +495,7 @@ class OrganizationSerializerTests(TestCase):
'homepage_url'
:
organization
.
homepage_url
,
'logo_image_url'
:
organization
.
logo_image_url
,
'tags'
:
[
TAG
],
'marketing_url'
:
organization
.
marketing_url
,
}
self
.
assertDictEqual
(
serializer
.
data
,
expected
)
...
...
course_discovery/apps/course_metadata/models.py
View file @
ba11ed8c
...
...
@@ -167,6 +167,13 @@ class Organization(TimeStampedModel):
def
__str__
(
self
):
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
):
""" Person model. """
...
...
course_discovery/apps/course_metadata/tests/factories.py
View file @
ba11ed8c
...
...
@@ -148,6 +148,7 @@ class OrganizationFactory(factory.DjangoModelFactory):
logo_image_url
=
FuzzyURL
()
banner_image_url
=
FuzzyURL
()
partner
=
factory
.
SubFactory
(
PartnerFactory
)
marketing_url_path
=
FuzzyText
()
class
Meta
:
model
=
Organization
...
...
course_discovery/apps/course_metadata/tests/test_models.py
View file @
ba11ed8c
...
...
@@ -166,10 +166,25 @@ class CourseRunTests(TestCase):
class
OrganizationTests
(
TestCase
):
""" Tests for the `Organization` model. """
def
setUp
(
self
):
super
(
OrganizationTests
,
self
)
.
setUp
()
self
.
organization
=
factories
.
OrganizationFactory
()
def
test_str
(
self
):
""" Verify casting an instance to a string returns a string containing the key and name. """
organization
=
factories
.
OrganizationFactory
()
self
.
assertEqual
(
str
(
organization
),
'{key}: {name}'
.
format
(
key
=
organization
.
key
,
name
=
organization
.
name
))
self
.
assertEqual
(
str
(
self
.
organization
),
'{key}: {name}'
.
format
(
key
=
self
.
organization
.
key
,
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
):
...
...
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