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
......@@ -5,3 +5,6 @@ djangorestframework==3.6.3
django-model-utils==3.0.0
mysqlclient==1.3.10
setuptools==36.0.1
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):
fieldsets = (
(None, {
'fields': ('name', 'facility_category', 'facility_location',
'main_schedule', 'special_schedules',
'main_schedule', 'special_schedules', 'tags',
'tapingo_url', 'owners'),
}),
)
......
......@@ -21,6 +21,7 @@ from django.core.validators import RegexValidator
# Other Imports
from model_utils.models import TimeStampedModel
from autoslug import AutoSlugField
from taggit.managers import TaggableManager
class Category(TimeStampedModel):
"""
......@@ -108,6 +109,7 @@ class Facility(TimeStampedModel):
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/',
code='invalid_tapingo_url')])
tags = TaggableManager()
def is_open(self):
"""
......
......@@ -15,6 +15,8 @@ from .models import Category, Facility, Schedule, OpenTime, Location, Alert
# Other Imports
from rest_framework import serializers
from taggit_serializer.serializers import (TagListSerializerField,
TaggitSerializer)
class AlertSerializer(serializers.ModelSerializer):
"""
......@@ -85,9 +87,12 @@ class FacilitySerializer(serializers.HyperlinkedModelSerializer):
# Append a serialized Schedule object to represent special_schedules
special_schedules = ScheduleSerializer(many=True, read_only=True)
tags = TagListSerializerField()
class Meta:
# Choose the model to be serialized
model = Facility
# List the fields that we are serializing
fields = ('id', 'facility_category', 'facility_location', 'tapingo_url',
'main_schedule', 'special_schedules', 'modified', 'name')
fields = ('id', 'facility_category', 'facility_location', 'tags',
'tapingo_url', 'main_schedule', 'special_schedules',
'modified', 'name')
......@@ -225,6 +225,10 @@ INSTALLED_APPS = (
# Apps specific for this project go here.
'api',
'rest_framework',
# Third party apps
'taggit',
'taggit_serializer'
)
########## 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