Skip to content

Commit

Permalink
customize category display
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed May 26, 2017
1 parent 25e263b commit ea70810
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 12 deletions.
29 changes: 29 additions & 0 deletions db/category/migrations/0002_auto_20170517_1648.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-05-17 16:48
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('category', '0001_initial'),
]

operations = [
migrations.AlterModelOptions(
name='category',
options={'ordering': ('order', 'name'), 'verbose_name': 'category', 'verbose_name_plural': 'categories'},
),
migrations.AddField(
model_name='category',
name='description',
field=models.TextField(blank=True, null=True, verbose_name='Description'),
),
migrations.AddField(
model_name='category',
name='order',
field=models.IntegerField(blank=True, null=True, verbose_name='Order'),
),
]
16 changes: 15 additions & 1 deletion db/category/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@ class Category(models.Model):
blank=True,
verbose_name="Wikipedia Link",
)
description = models.TextField(
null=True,
blank=True,
verbose_name="Description",
)
order = models.IntegerField(
null=True,
blank=True,
verbose_name="Order",
)

def __str__(self):
return self.name

class Meta:
verbose_name = "category"
verbose_name_plural = "categorys"
verbose_name_plural = "categories"
ordering = ('order', 'name',)
11 changes: 6 additions & 5 deletions templates/category_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{>home}}
<h1>{{label}}</h1>
{{#page_config.can_change}}
<a href="{{rt}}/categorys/{{id}}/edit" data-icon="edit" data-transition="flip">
<a href="{{rt}}/categories/{{id}}/edit" data-icon="edit" data-transition="flip">
Edit
</a>
{{/page_config.can_change}}
Expand All @@ -23,12 +23,13 @@ <h1>{{label}}</h1>
<td>{{name}}</td>
</tr>
<tr>
<th>Wikipedia Link</th>
<td>{{link}}</td>
<th>Description</th>
<td>{{description}}</td>
</tr>
</table>
<h3>Photo</h3>
<img src="{{photo}}" alt="Photo - {{label}}" style="max-width:100%">
<ul data-role="listview" data-inset="true">
<li data-icon="bullets"><a href="{{rt}}/categories/{{id}}/observations">View Observations</a></li>
</ul>
</div>
</div>
</body>
Expand Down
16 changes: 13 additions & 3 deletions templates/category_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<h1>{{^id}}Add{{/id}}{{#id}}Edit{{/id}} category</h1>
{{#id}}
{{#page_config.can_delete}}
<form action="{{svc}}/categorys/{{id}}" method="post" data-ajax="false"
<form action="{{svc}}/categories/{{id}}" method="post" data-ajax="false"
data-wq-json="true" data-wq-background-sync="false"
onsubmit="return require('wq/app').confirmSubmit(this, 'Are you sure you want to delete this record?');">
{{>csrf}}
Expand All @@ -24,7 +24,7 @@ <h1>{{^id}}Add{{/id}}{{#id}}Edit{{/id}} category</h1>
{{/id}}
</div>
<div role="main" class="ui-content">
<form action="{{svc}}/categorys/{{id}}" method="post" data-ajax="false"
<form action="{{svc}}/categories/{{id}}" method="post" data-ajax="false"
data-wq-json="true"
{{#outbox_id}}
data-wq-outbox-id="{{outbox_id}}"
Expand Down Expand Up @@ -82,10 +82,20 @@ <h1>{{^id}}Add{{/id}}{{#id}}Edit{{/id}} category</h1>
<textarea id='category-link' name='link' data-xform-type="text">{{link}}</textarea>
<p class='error category-link-errors'></p>
</li>
<li class="ui-field-contain">
<label for='category-description'>Description</label>
<textarea id='category-description' name='description' data-xform-type="text">{{description}}</textarea>
<p class='error category-description-errors'></p>
</li>
<li class="ui-field-contain">
<label for='category-order'>Order</label>
<input id='category-order' type='number' data-xform-type='int' name='order' value="{{order}}">
<p class='error category-order-errors'></p>
</li>
<li>
<div class="ui-grid-a">
<div class="ui-block-a">
<a href="{{rt}}/categorys/{{id}}" data-role="button" data-icon="back" data-direction="reverse">
<a href="{{rt}}/categories/{{id}}" data-role="button" data-icon="back" data-direction="reverse">
Back
</a>
</div>
Expand Down
6 changes: 3 additions & 3 deletions templates/category_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{>home}}
<h1>category List{{#parent_id}} for {{parent_label}}{{/parent_id}}</h1>
{{#page_config.can_add}}
<a href="{{rt}}/categorys/new{{#parent_id}}?{{parent_page}}_id={{parent_id}}{{/parent_id}}" data-icon="plus">
<a href="{{rt}}/categories/new{{#parent_id}}?{{parent_page}}_id={{parent_id}}{{/parent_id}}" data-icon="plus">
Add New
</a>
{{/page_config.can_add}}
Expand Down Expand Up @@ -57,12 +57,12 @@ <h1>category List{{#parent_id}} for {{parent_label}}{{/parent_id}}</h1>
{{/unsynced}}
{{#list}}
<li>
<a href="{{rt}}/categorys/{{id}}">{{label}}</a>
<a href="{{rt}}/categories/{{id}}">{{label}}</a>
</li>
{{/list}}
{{#page_config.can_add}}
<li data-icon="plus" data-theme="b">
<a href="{{rt}}/categorys/new{{#parent_id}}?{{parent_page}}_id={{parent_id}}{{/parent_id}}">Add category</a>
<a href="{{rt}}/categories/new{{#parent_id}}?{{parent_page}}_id={{parent_id}}{{/parent_id}}">Add category</a>
</li>
{{/page_config.can_add}}
</ul>
Expand Down

0 comments on commit ea70810

Please sign in to comment.