...
 
Commits (3)
......@@ -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')
......@@ -17,11 +17,14 @@ window.W = window.W || {};
var router = new W.ScoreRouter({application: this});
$(document).on("click", "a", function(e) {
e.preventDefault(); // This is important
// Do not interfere with Backbone Paginator.
if (! e.isDefaultPrevented()) {
e.preventDefault(); // This is important
var href = $(e.currentTarget).attr('href');
var href = $(e.currentTarget).attr('href');
router.navigate(href, true);
router.navigate(href, true);
};
});
/** Starts the URL handling framework */
......
......@@ -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
......
......@@ -10,7 +10,7 @@
<nav>
<% if (username) { %>
Bienvenue <%- username %>
Bienvenue <a href="/users/<%- pk %>"><%- username %></a>
<% } else { %>
Bienvenue anonymous
<% } %>
......
......@@ -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