Commit 11ab2592 by alexandre

Proper tag support (comma separated values).

Update requirements and migrate
parent 35462696
......@@ -26,6 +26,9 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'taggit',
'taggit_serializer',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
......
from django.db import models
from django.contrib.postgres.fields import JSONField
from taggit.managers import TaggableManager
class Attachment(models.Model):
......@@ -29,6 +30,7 @@ class Score(models.Model):
duration = models.TextField(blank=True)
genre = models.TextField(blank=True)
tags = models.TextField(blank=True)
tags = TaggableManager()
mainline = JSONField(blank=True)
language = models.TextField(blank=True)
......
from .models import Attachment, Score
from rest_framework import serializers
from rest_framework_recursive.fields import RecursiveField
from taggit_serializer.serializers import (TagListSerializerField,
TaggitSerializer)
class AttachmentSerializer(serializers.HyperlinkedModelSerializer):
......@@ -12,8 +14,9 @@ class AttachmentSerializer(serializers.HyperlinkedModelSerializer):
# read_only_fields = ('attachment',)
class ScoreSerializer(serializers.HyperlinkedModelSerializer):
class ScoreSerializer(TaggitSerializer, serializers.HyperlinkedModelSerializer):
id = serializers.ReadOnlyField()
tags = TagListSerializerField()
class Meta:
model = Score
......@@ -25,7 +28,8 @@ class ScoreLightSerializer(serializers.HyperlinkedModelSerializer):
representation.
"""
id = serializers.ReadOnlyField()
tags = TagListSerializerField()
class Meta:
model = Score
fields = ('id', 'title', 'created_at', 'updated_at')
fields = ('id', 'title', 'tags', 'created_at', 'updated_at')
......@@ -51,6 +51,11 @@ window.W = window.W || {};
cell: MyDatetimeCell
},
{
name: "tags",
label: "Tags",
cell: "string",
},
{
name: "score_type",
label: "Type",
cell: "string",
......@@ -1043,7 +1048,7 @@ window.W = window.W || {};
effectif: this.getChildView('effectif').value(),
stage_set: this.fieldVal('stage_set'),
duration: this.fieldVal('duration'),
tags: this.fieldVal('tags'),
tags: this.fieldVal('tags').trim().split(/\s*,\s*/),
language: this.fieldVal('language')
};
......@@ -1421,6 +1426,24 @@ window.W = window.W || {};
});
var myPaginationView = new Backgrid.Extension.Paginator({
controls : {
rewind: {
label: "《",
title: "First"
},
back: {
label: "〈",
title: "Previous"
},
forward: {
label: "〉",
title: "Next"
},
fastForward: {
label: "》",
title: "Last"
}
},
// If you anticipate a large number of pages, you can adjust
// the number of page handles to show. The sliding window
......
......@@ -71,7 +71,7 @@
<dd class="extended">
<ul>
<%
tag_list = tags.split(';');
tag_list = tags;
for (var i=0; i < tag_list.length; i++) { %>
<li><%- tag_list[i] %></li>
......@@ -105,4 +105,4 @@
<div id="axis-wrapper">
<ol></ol>
</div>
</div>
\ No newline at end of file
</div>
......@@ -5,3 +5,5 @@ django-rest-auth
psycopg2
django-filter
django-compressor
django-taggit
django-taggit-serializer
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