Commit 1107f00b authored by gijs's avatar gijs

Added language field

parent fb273828
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-01-30 18:25
from __future__ import unicode_literals
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('playground', '0012_auto_20180130_1215'),
]
operations = [
migrations.AddField(
model_name='score',
name='language',
field=models.TextField(blank=True),
),
]
......@@ -29,6 +29,7 @@ class Score(models.Model):
genre = models.TextField(blank=True)
tags = models.TextField(blank=True)
mainline = JSONField(blank=True)
language = models.TextField(blank=True)
def __str__(self):
return self.title
......
......@@ -20,6 +20,7 @@ window.W = window.W || {};
performance_author: "",
presentation: "",
effectif: "",
language: "",
},
urlRoot: '/api/scores/',
......
......@@ -14,8 +14,50 @@ window.W = window.W || {};
};
var languages = [
{
patt: /en/,
label: 'English'
},
{
patt: /fr/,
label: 'Français'
},
{
patt: /nl/,
label: 'Nederlands'
},
{
patt: /es/,
label: 'Español'
},
{
patt: /de/,
label: 'Deutsch'
}
];
var tags = W.tags = [">", "|", "//", "", "||"];
function getUserLanguage() {
var l = navigator.language;
for (var i = 0; i < languages.length; i++) {
if (l.search(languages[i].patt) > -1) {
return languages[i].label;
}
}
}
function formatTimestamp(timestring) {
var d = new Date(timestring);
return d.getDate()
+ '-' + (d.getMonth() + 1)
+ '-' + d.getFullYear()
+ ' ' + d.getHours()
+ ':' + d.getMinutes();
}
/**
* Instantiate with at least a label.
*/
......@@ -853,7 +895,10 @@ window.W = window.W || {};
},
templateContext: function () {
return { rangeType: rangeType };
return {
rangeType: rangeType,
getUserLanguage: getUserLanguage
};
},
/**
......@@ -920,7 +965,8 @@ window.W = window.W || {};
effectif: this.getChildView('effectif').value(),
stage_set: this.fieldVal('stage_set'),
duration: this.fieldVal('duration'),
genre: this.fieldVal('genre'),
tags: this.fieldVal('tags'),
language: this.fieldVal('language')
};
this.trigger('form:submit', data);
......@@ -979,7 +1025,8 @@ window.W = window.W || {};
return {
hasChanges: this.hasChanges,
depth: this.model.getDepth(),
rangeType: rangeType
rangeType: rangeType,
formatTimestamp: formatTimestamp
};
},
......
......@@ -48,10 +48,16 @@
<input type="text" name="duration" value="<%= duration %>">
</label>
<!-- Genre -->
<!-- Tags -->
<label>
<span class="label-text">Genre: </span>
<input type="text" name="genre" value="<%= genre %>">
<span class="label-text">Tags: </span>
<input type="text" name="tags" value="<%= tags %>">
</label>
<!-- Language -->
<label>
<span class="label-text">Language: </span>
<input type="text" name="language" value="<%= (language) ? language : getUserLanguage() %>">
</label>
<button data-name="close">Annuler</button>
......
......@@ -70,6 +70,14 @@
<dt>Genre</dt>
<dd><%= genre %></dd>
<% } %>
<dt>Publié le</dt>
<dd><%= formatTimestamp(created_at) %></dd>
<dt>Modifié le</dt>
<dd><%= formatTimestamp(updated_at) %></dd>
<% if (language) { %>
<dt>Langue</dt>
<dd><%= language %></dd>
<% } %>
</dl>
<form></form>
......
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