Skip to content
Snippets Groups Projects
Commit 2cc61cbd authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Better filtering of message list

parent b32b4eec
Branches
No related tags found
No related merge requests found
Showing
with 146 additions and 54 deletions
No preview for this file type
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: VIPS\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-13 13:36+0100\n"
"POT-Creation-Date: 2016-07-06 15:21+0200\n"
"PO-Revision-Date: 2015-02-13 11:14+0100\n"
"Last-Translator: Vjekoslav vujica <wvjeko@gmail.com>\n"
"Language-Team: \n"
......@@ -15,11 +15,11 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Poedit 1.7.4\n"
#: templates/organisms/index.html:3
#: templates/organisms/index.html.py:5
#: templates/organisms/index.html:3 templates/organisms/index.html.py:5
msgid "Organisms"
msgstr "Organizama"
......@@ -30,4 +30,3 @@ msgstr "Usjevi "
#: templates/organisms/index.html:6
msgid "Crop"
msgstr "Usjevi "
No preview for this file type
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-13 13:36+0100\n"
"POT-Creation-Date: 2016-07-06 15:21+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -28,7 +28,6 @@ msgid "Crops"
msgstr "Kulturer"
#: templates/organisms/index.html:6
#, fuzzy
msgid "Crop"
msgstr "Kultur"
No preview for this file type
......@@ -7,14 +7,14 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-05-27 13:40+0200\n"
"POT-Creation-Date: 2016-07-06 15:21+0200\n"
"PO-Revision-Date: 2016-06-01 11:48+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 1.8.7\n"
#: templates/organisms/index.html:3 templates/organisms/index.html.py:5
......
No preview for this file type
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-21 15:44+0200\n"
"POT-Creation-Date: 2016-07-06 15:22+0200\n"
"PO-Revision-Date: 2014-05-14 09:25+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -18,6 +18,22 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.6.5\n"
#: models.py:196 templates/messages/index.html:49
msgid "Headline"
msgstr "Заглавие"
#: models.py:198
msgid "Date published"
msgstr ""
#: models.py:199
msgid "Date expired"
msgstr ""
#: models.py:200
msgid "Illustration"
msgstr ""
#: templates/messages/index.html:3 templates/messages/index.html.py:9
msgid "Messages"
msgstr "Съобщения"
......@@ -27,7 +43,7 @@ msgid "Text search"
msgstr ""
#: templates/messages/index.html:20
msgid "All crops"
msgid "All crop categories"
msgstr ""
#: templates/messages/index.html:31
......@@ -47,10 +63,10 @@ msgid "Publish date"
msgstr "Дата на издаване"
#: templates/messages/index.html:48
msgid "Headline"
msgstr "Заглавие"
msgid "Crop group(s)"
msgstr ""
#: templates/messages/index.html:49
#: templates/messages/index.html:50
msgid "Author"
msgstr "Автор"
......
No preview for this file type
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: VIPS\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-21 15:44+0200\n"
"POT-Creation-Date: 2016-07-06 15:22+0200\n"
"PO-Revision-Date: 2015-02-13 11:13+0100\n"
"Last-Translator: Vjekoslav vujica <wvjeko@gmail.com>\n"
"Language-Team: \n"
......@@ -19,6 +19,22 @@ msgstr ""
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Poedit 1.7.4\n"
#: models.py:196 templates/messages/index.html:49
msgid "Headline"
msgstr "Naslov "
#: models.py:198
msgid "Date published"
msgstr ""
#: models.py:199
msgid "Date expired"
msgstr ""
#: models.py:200
msgid "Illustration"
msgstr ""
#: templates/messages/index.html:3 templates/messages/index.html.py:9
msgid "Messages"
msgstr "Poruke "
......@@ -28,7 +44,7 @@ msgid "Text search"
msgstr ""
#: templates/messages/index.html:20
msgid "All crops"
msgid "All crop categories"
msgstr ""
#: templates/messages/index.html:31
......@@ -48,10 +64,10 @@ msgid "Publish date"
msgstr "Datum objave "
#: templates/messages/index.html:48
msgid "Headline"
msgstr "Naslov "
msgid "Crop group(s)"
msgstr ""
#: templates/messages/index.html:49
#: templates/messages/index.html:50
msgid "Author"
msgstr "Autor "
......
No preview for this file type
......@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-21 15:44+0200\n"
"POT-Creation-Date: 2016-07-06 15:22+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -30,6 +30,23 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: models.py:196
#: templates/messages/index.html:49
msgid "Headline"
msgstr "Overskrift"
#: models.py:198
msgid "Date published"
msgstr "Dato publisert"
#: models.py:199
msgid "Date expired"
msgstr "Dato utløpt"
#: models.py:200
msgid "Illustration"
msgstr "Illustrasjon"
#: templates/messages/index.html:3
#: templates/messages/index.html.py:9
msgid "Messages"
......@@ -40,8 +57,8 @@ msgid "Text search"
msgstr "Fritekstsøk"
#: templates/messages/index.html:20
msgid "All crops"
msgstr "Alle kulturer"
msgid "All crop categories"
msgstr "Alle kulturgrupper"
#: templates/messages/index.html:31
msgid "From"
......@@ -60,10 +77,10 @@ msgid "Publish date"
msgstr "Publiseringsdato"
#: templates/messages/index.html:48
msgid "Headline"
msgstr "Overskrift"
msgid "Crop group(s)"
msgstr "Kulturgruppe(r)"
#: templates/messages/index.html:49
#: templates/messages/index.html:50
msgid "Author"
msgstr "Forfatter"
No preview for this file type
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-01-09 09:57+0100\n"
"POT-Creation-Date: 2016-07-06 15:22+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -18,6 +18,22 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: models.py:196 templates/messages/index.html:49
msgid "Headline"
msgstr ""
#: models.py:198
msgid "Date published"
msgstr ""
#: models.py:199
msgid "Date expired"
msgstr ""
#: models.py:200
msgid "Illustration"
msgstr ""
#: templates/messages/index.html:3 templates/messages/index.html.py:9
msgid "Messages"
msgstr ""
......@@ -27,7 +43,7 @@ msgid "Text search"
msgstr ""
#: templates/messages/index.html:20
msgid "All crops"
msgid "All crop categories"
msgstr ""
#: templates/messages/index.html:31
......@@ -47,9 +63,9 @@ msgid "Publish date"
msgstr ""
#: templates/messages/index.html:48
msgid "Headline"
msgid "Crop group(s)"
msgstr ""
#: templates/messages/index.html:49
#: templates/messages/index.html:50
msgid "Author"
msgstr ""
No preview for this file type
......@@ -7,18 +7,17 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-05-27 13:40+0200\n"
"POT-Creation-Date: 2016-07-06 15:22+0200\n"
"PO-Revision-Date: 2016-06-01 11:50+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 1.8.7\n"
#: models.py:196
#: templates/messages/index.html:48
#: models.py:196 templates/messages/index.html:49
msgid "Headline"
msgstr "标题"
......@@ -34,8 +33,7 @@ msgstr "过期日期"
msgid "Illustration"
msgstr "图"
#: templates/messages/index.html:3
#: templates/messages/index.html.py:9
#: templates/messages/index.html:3 templates/messages/index.html.py:9
msgid "Messages"
msgstr "新闻"
......@@ -44,7 +42,9 @@ msgid "Text search"
msgstr "搜索文本"
#: templates/messages/index.html:20
msgid "All crops"
#, fuzzy
#| msgid "All crops"
msgid "All crop categories"
msgstr "所有作物"
#: templates/messages/index.html:31
......@@ -63,7 +63,10 @@ msgstr "搜索日期"
msgid "Publish date"
msgstr "发布日期"
#: templates/messages/index.html:49
#: templates/messages/index.html:48
msgid "Crop group(s)"
msgstr ""
#: templates/messages/index.html:50
msgid "Author"
msgstr "作者"
......@@ -75,7 +75,7 @@ class Message:
illustration_file_name,
illustration_caption,
created_by,
message_crop_organism_ids
crop_category_ids
):
self.message_id = message_id
self.organization_id = organization_id
......@@ -87,7 +87,7 @@ class Message:
self.illustration_file_name = illustration_file_name
self.illustration_caption = illustration_caption
self.created_by = created_by
self.message_crop_organism_ids = message_crop_organism_ids
self.crop_category_ids = crop_category_ids
def get_illustration_url(self):
return "http://%s/static/images/messages/%s/%s" % (settings.VIPSLOGIC_SERVER_NAME,self.organization_id,self.illustration_file_name)
......@@ -159,7 +159,7 @@ class Message:
message_illustration.get("file_name", None),
message_illustration.get("caption", None),
created_by,
the_dict.get("messageCropOrganismIds",[])
the_dict.get("cropCategoryIds",[])
)
@staticmethod
......
......@@ -16,10 +16,10 @@
</div>
<div class="col-xs-3">
<div class="form-group">
<select name="cropOrganismIds" class="form-control chosen-select" onchange="cropFilter(this);">
<option value="-1">{% trans "All crops" %}</option>
{% for crop in crops %}
<option value="{{crop.organism_id}}">{{crop.local_name}} ({{crop.latin_name}})</option>
<select name="cropCategoryIds" class="form-control chosen-select" onchange="cropCategoryFilter(this);">
<option value="-1">{% trans "All crop categories" %}</option>
{% for crop_category in crop_categories %}
<option value="{{crop_category.crop_category_id}}">{{crop_category.name}}</option>
{% endfor %}
</select>
</div>
......@@ -45,6 +45,7 @@
<thead>
<tr>
<th>{% trans "Publish date" %}</th>
<th>{% trans "Crop group(s)" %}</th>
<th>{% trans "Headline" %}</th>
<th>{% trans "Author" %}</th>
</tr>
......@@ -72,11 +73,22 @@
body: "{{ message.body | escapejs }}",
createdBy:"{{ message.created_by }}",
url:"{% url 'vips_messages:detail' message.message_id %}",
messageCropOrganismIds:{{message.message_crop_organism_ids}}
cropCategoryIds:{{message.crop_category_ids}}
} {% if not forloop.last %},{% endif %}
{% endfor %}
];
var cropCategories = [
{% for crop_category in crop_categories %}
{
cropCategoryId: {{ crop_category.crop_category_id }},
name: "{{ crop_category.name }}",
cropIds: {{ crop_category.crop_ids }}
}
{% if not forloop.last %},{% endif %}
{% endfor %}
];
var messageListSubset;
/**
......@@ -92,9 +104,22 @@
for(var i in messageListSubset)
{
var listItem = messageListSubset[i];
// Get the crop groups
var cropGroupNames = [];
for(var j in listItem.cropCategoryIds)
{
for(var k in cropCategories)
{
if(cropCategories[k].cropCategoryId == listItem.cropCategoryIds[j])
{
cropGroupNames.push(cropCategories[k].name);
}
}
}
HTML += [
'<tr>',
'<td>',listItem.datePub,'</td>',
'<td>', cropGroupNames.join(", "),'</td>',
'<td><a href="',listItem.url,'">',listItem.heading,'</a></td>',
'<td>',listItem.createdBy,'</td>',
'</tr>']
......@@ -132,12 +157,12 @@
/**
* Filters messages based on selected crops. Resets the text search
*/
function cropFilter(cropSelectList)
function cropCategoryFilter(cropCategorySelectList)
{
// Reset text search field
document.getElementById("textSearchField").value="";
var selectedCropOrganismId = parseInt(cropSelectList.options[cropSelectList.selectedIndex].value);
if(selectedCropOrganismId == -1)
var selectedCropCategoryId = parseInt(cropCategorySelectList.options[cropCategorySelectList.selectedIndex].value);
if(selectedCropCategoryId == -1)
{
messageListSubset = messageList;
}
......@@ -147,9 +172,9 @@
for(var i in messageList)
{
var message = messageList[i];
for(var j in message.messageCropOrganismIds)
for(var j in message.cropCategoryIds)
{
if(message.messageCropOrganismIds[j] == selectedCropOrganismId)
if(message.cropCategoryIds[j] == selectedCropCategoryId)
{
messageListSubset.push(message);
break;
......
......@@ -24,7 +24,7 @@ from django.http import HttpResponse
from vips_messages.models import Message
from vips_messages.forms import MessagePublishedDateFilterForm
from organisms.models import Organism
from organisms.models import Organism, CropCategory
def index(request):
messages = None
......@@ -47,6 +47,7 @@ def index(request):
context = {
'messages' : messages,
'crop_categories': CropCategory.get_crop_categories(translation.get_language()),
'form' : form,
'crops' : crops
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment