Commit ffc90083 authored by David Haynes's avatar David Haynes
Browse files

First pass on food tags for facilities

- using some great libs
- it just works
- needs docs
parent 676555d8
Pipeline #1409 failed with stage
in 1 minute and 4 seconds
...@@ -4,4 +4,7 @@ django-cas-client==1.3.0 ...@@ -4,4 +4,7 @@ django-cas-client==1.3.0
djangorestframework==3.6.3 djangorestframework==3.6.3
django-model-utils==3.0.0 django-model-utils==3.0.0
mysqlclient==1.3.10 mysqlclient==1.3.10
setuptools==36.0.1 setuptools==36.0.1
\ No newline at end of file django-taggit==0.22.0
django-taggit-serializer==0.1.5
six
\ No newline at end of file
...@@ -28,7 +28,7 @@ class FacilityAdmin(admin.ModelAdmin): ...@@ -28,7 +28,7 @@ class FacilityAdmin(admin.ModelAdmin):
fieldsets = ( fieldsets = (
(None, { (None, {
'fields': ('name', 'facility_category', 'facility_location', 'fields': ('name', 'facility_category', 'facility_location',
'main_schedule', 'special_schedules', 'main_schedule', 'special_schedules', 'tags',
'tapingo_url', 'owners'), 'tapingo_url', 'owners'),
}), }),
) )
......
...@@ -21,6 +21,7 @@ from django.core.validators import RegexValidator ...@@ -21,6 +21,7 @@ from django.core.validators import RegexValidator
# Other Imports # Other Imports
from model_utils.models import TimeStampedModel from model_utils.models import TimeStampedModel
from autoslug import AutoSlugField from autoslug import AutoSlugField
from taggit.managers import TaggableManager
class Category(TimeStampedModel): class Category(TimeStampedModel):
""" """
...@@ -108,6 +109,7 @@ class Facility(TimeStampedModel): ...@@ -108,6 +109,7 @@ class Facility(TimeStampedModel):
tapingo_url = models.URLField(blank=True, validators=[RegexValidator(regex='^https:\/\/www.tapingo.com\/', tapingo_url = models.URLField(blank=True, validators=[RegexValidator(regex='^https:\/\/www.tapingo.com\/',
message='The link is not a valid tapingo link. Example: https://www.tapingo.com/order/restaurant/starbucks-gmu-johnson/', message='The link is not a valid tapingo link. Example: https://www.tapingo.com/order/restaurant/starbucks-gmu-johnson/',
code='invalid_tapingo_url')]) code='invalid_tapingo_url')])
tags = TaggableManager()
def is_open(self): def is_open(self):
""" """
......
...@@ -15,6 +15,8 @@ from .models import Category, Facility, Schedule, OpenTime, Location, Alert ...@@ -15,6 +15,8 @@ from .models import Category, Facility, Schedule, OpenTime, Location, Alert
# Other Imports # Other Imports
from rest_framework import serializers from rest_framework import serializers
from taggit_serializer.serializers import (TagListSerializerField,
TaggitSerializer)
class AlertSerializer(serializers.ModelSerializer): class AlertSerializer(serializers.ModelSerializer):
""" """
...@@ -85,9 +87,12 @@ class FacilitySerializer(serializers.HyperlinkedModelSerializer): ...@@ -85,9 +87,12 @@ class FacilitySerializer(serializers.HyperlinkedModelSerializer):
# Append a serialized Schedule object to represent special_schedules # Append a serialized Schedule object to represent special_schedules
special_schedules = ScheduleSerializer(many=True, read_only=True) special_schedules = ScheduleSerializer(many=True, read_only=True)
tags = TagListSerializerField()
class Meta: class Meta:
# Choose the model to be serialized # Choose the model to be serialized
model = Facility model = Facility
# List the fields that we are serializing # List the fields that we are serializing
fields = ('id', 'facility_category', 'facility_location', 'tapingo_url', fields = ('id', 'facility_category', 'facility_location', 'tags',
'main_schedule', 'special_schedules', 'modified', 'name') 'tapingo_url', 'main_schedule', 'special_schedules',
'modified', 'name')
...@@ -225,6 +225,10 @@ INSTALLED_APPS = ( ...@@ -225,6 +225,10 @@ INSTALLED_APPS = (
# Apps specific for this project go here. # Apps specific for this project go here.
'api', 'api',
'rest_framework', 'rest_framework',
# Third party apps
'taggit',
'taggit_serializer'
) )
########## END APP CONFIGURATION ########## END APP CONFIGURATION
......
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