Commit 1cadc799 by Clinton Blackburn

Updated Organization model

- Added marketing URL path
- Added tags

ECOM-5191
parent 33198721
...@@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _
from drf_haystack.serializers import HaystackSerializer, HaystackFacetSerializer from drf_haystack.serializers import HaystackSerializer, HaystackFacetSerializer
from rest_framework import serializers from rest_framework import serializers
from rest_framework.fields import DictField from rest_framework.fields import DictField
from taggit_serializer.serializers import TagListSerializerField, TaggitSerializer
from course_discovery.apps.catalogs.models import Catalog from course_discovery.apps.catalogs.models import Catalog
from course_discovery.apps.course_metadata.models import ( from course_discovery.apps.course_metadata.models import (
...@@ -155,12 +156,13 @@ class PersonSerializer(serializers.ModelSerializer): ...@@ -155,12 +156,13 @@ class PersonSerializer(serializers.ModelSerializer):
fields = ('key', 'name', 'title', 'bio', 'profile_image',) fields = ('key', 'name', 'title', 'bio', 'profile_image',)
class OrganizationSerializer(serializers.ModelSerializer): class OrganizationSerializer(TaggitSerializer, serializers.ModelSerializer):
"""Serializer for the ``Organization`` model.""" """Serializer for the ``Organization`` model."""
tags = TagListSerializerField()
class Meta(object): class Meta(object):
model = Organization model = Organization
fields = ('key', 'name', 'description', 'homepage_url',) fields = ('key', 'name', 'description', 'homepage_url', 'tags',)
class CatalogSerializer(serializers.ModelSerializer): class CatalogSerializer(serializers.ModelSerializer):
......
...@@ -387,6 +387,8 @@ class VideoSerializerTests(TestCase): ...@@ -387,6 +387,8 @@ class VideoSerializerTests(TestCase):
class OrganizationSerializerTests(TestCase): class OrganizationSerializerTests(TestCase):
def test_data(self): def test_data(self):
organization = OrganizationFactory() organization = OrganizationFactory()
TAG = 'test'
organization.tags.add(TAG)
serializer = OrganizationSerializer(organization) serializer = OrganizationSerializer(organization)
expected = { expected = {
...@@ -394,6 +396,7 @@ class OrganizationSerializerTests(TestCase): ...@@ -394,6 +396,7 @@ class OrganizationSerializerTests(TestCase):
'name': organization.name, 'name': organization.name,
'description': organization.description, 'description': organization.description,
'homepage_url': organization.homepage_url, 'homepage_url': organization.homepage_url,
'tags': [TAG],
} }
self.assertDictEqual(serializer.data, expected) self.assertDictEqual(serializer.data, expected)
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import taggit.managers
class Migration(migrations.Migration):
dependencies = [
('taggit', '0002_auto_20150616_2121'),
('course_metadata', '0016_auto_20160815_1438'),
]
operations = [
migrations.AddField(
model_name='historicalorganization',
name='marketing_url_path',
field=models.CharField(null=True, max_length=255, blank=True),
),
migrations.AddField(
model_name='organization',
name='marketing_url_path',
field=models.CharField(null=True, max_length=255, blank=True),
),
migrations.AddField(
model_name='organization',
name='tags',
field=taggit.managers.TaggableManager(verbose_name='Tags', to='taggit.Tag', through='taggit.TaggedItem', help_text='A comma-separated list of tags.', blank=True),
),
]
...@@ -14,6 +14,7 @@ from djchoices import DjangoChoices, ChoiceItem ...@@ -14,6 +14,7 @@ from djchoices import DjangoChoices, ChoiceItem
from haystack.query import SearchQuerySet from haystack.query import SearchQuerySet
from simple_history.models import HistoricalRecords from simple_history.models import HistoricalRecords
from sortedm2m.fields import SortedManyToManyField from sortedm2m.fields import SortedManyToManyField
from taggit.managers import TaggableManager
from course_discovery.apps.core.models import Currency, Partner from course_discovery.apps.core.models import Currency, Partner
from course_discovery.apps.course_metadata.query import CourseQuerySet from course_discovery.apps.course_metadata.query import CourseQuerySet
...@@ -156,11 +157,14 @@ class Organization(TimeStampedModel): ...@@ -156,11 +157,14 @@ class Organization(TimeStampedModel):
uuid = models.UUIDField(blank=False, null=False, default=uuid4, editable=False, verbose_name=_('UUID')) uuid = models.UUIDField(blank=False, null=False, default=uuid4, editable=False, verbose_name=_('UUID'))
key = models.CharField(max_length=255) key = models.CharField(max_length=255)
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
marketing_url_path = models.CharField(max_length=255, null=True, blank=True)
description = models.TextField(null=True, blank=True) description = models.TextField(null=True, blank=True)
homepage_url = models.URLField(max_length=255, null=True, blank=True) homepage_url = models.URLField(max_length=255, null=True, blank=True)
logo_image_url = models.URLField(null=True, blank=True) logo_image_url = models.URLField(null=True, blank=True)
banner_image_url = models.URLField(null=True, blank=True) banner_image_url = models.URLField(null=True, blank=True)
history = HistoricalRecords() history = HistoricalRecords()
tags = TaggableManager(blank=True)
class Meta: class Meta:
unique_together = ( unique_together = (
......
...@@ -45,6 +45,9 @@ THIRD_PARTY_APPS = [ ...@@ -45,6 +45,9 @@ THIRD_PARTY_APPS = [
'django_filters', 'django_filters',
'django_fsm', 'django_fsm',
'storages', 'storages',
'django_comments',
'taggit',
'taggit_serializer',
] ]
PROJECT_APPS = [ PROJECT_APPS = [
...@@ -56,7 +59,6 @@ PROJECT_APPS = [ ...@@ -56,7 +59,6 @@ PROJECT_APPS = [
'course_discovery.apps.edx_haystack_extensions', 'course_discovery.apps.edx_haystack_extensions',
'course_discovery.apps.publisher', 'course_discovery.apps.publisher',
'course_discovery.apps.publisher_comments', 'course_discovery.apps.publisher_comments',
'django_comments',
] ]
...@@ -359,3 +361,5 @@ DEFAULT_PARTNER_ID = None ...@@ -359,3 +361,5 @@ DEFAULT_PARTNER_ID = None
# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id # See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1 SITE_ID = 1
COMMENTS_APP = 'course_discovery.apps.publisher_comments' COMMENTS_APP = 'course_discovery.apps.publisher_comments'
TAGGIT_CASE_INSENSITIVE = True
...@@ -12,6 +12,8 @@ django-libsass==0.7 ...@@ -12,6 +12,8 @@ django-libsass==0.7
django-simple-history==1.8.1 django-simple-history==1.8.1
django-sortedm2m==1.3.2 django-sortedm2m==1.3.2
django-storages==1.5.0 django-storages==1.5.0
django-taggit==0.20.2
django-taggit-serializer==0.1.5
django-waffle==0.11.1 django-waffle==0.11.1
djangorestframework==3.3.3 djangorestframework==3.3.3
djangorestframework-csv==1.4.1 djangorestframework-csv==1.4.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment