Commit eb81dac2 authored by David Haynes's avatar David Haynes 🙆
Browse files

Merge branch '40-facility-food-tags' into 'master'

Resolve "Add tags for various types of food"

Closes #40

See merge request !22
parents 676555d8 9ce5bb7e
Pipeline #1413 passed with stage
in 1 minute and 5 seconds
......@@ -4,4 +4,7 @@ django-cas-client==1.3.0
djangorestframework==3.6.3
django-model-utils==3.0.0
mysqlclient==1.3.10
setuptools==36.0.1
\ No newline at end of file
setuptools==36.0.1
django-taggit==0.22.1
django-taggit-serializer==0.1.5
six==1.10.0
\ No newline at end of file
......@@ -28,8 +28,8 @@ class FacilityAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': ('name', 'facility_category', 'facility_location',
'main_schedule', 'special_schedules',
'tapingo_url', 'owners'),
'main_schedule', 'special_schedules',
'facility_product_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,9 @@ 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')])
# A comma seperate list of words that neatly an aptly describe the product
# that this facility produces. (ex. for Taco Bell: mexican, taco, cheap)
facility_product_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):
"""
......@@ -84,10 +86,14 @@ class FacilitySerializer(serializers.HyperlinkedModelSerializer):
main_schedule = ScheduleSerializer(many=False, read_only=True)
# Append a serialized Schedule object to represent special_schedules
special_schedules = ScheduleSerializer(many=True, read_only=True)
# Append a serialized TagList object that represents the product tags for a
# Facility
facility_product_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',
'facility_product_tags', 'tapingo_url', 'main_schedule',
'special_schedules', 'modified', 'name')
......@@ -224,6 +224,10 @@ INSTALLED_APPS = (
# Apps specific for this project go here.
'api',
# Third party apps
'taggit',
'taggit_serializer',
'rest_framework',
)
......
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