From f230fbc1358cf30cd69922602cc95acbfae91330 Mon Sep 17 00:00:00 2001 From: Skia Date: Wed, 27 Jul 2016 17:23:02 +0200 Subject: [PATCH] Add product management views --- club/views.py | 4 +-- core/migrations/0008_pagerev_revision.py | 20 +++++++++++++++ core/models.py | 3 +++ core/templates/core/base.jinja | 1 + core/templates/core/macros.jinja | 3 +++ core/templates/core/page_detail.jinja | 2 +- core/templates/core/page_hist.jinja | 18 ++++++++----- core/templates/core/user_tools.jinja | 1 + counter/models.py | 3 +++ counter/templates/counter/product_list.jinja | 23 +++++++++++++++++ counter/urls.py | 3 +++ counter/views.py | 27 ++++++++++++++++++++ 12 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 core/migrations/0008_pagerev_revision.py create mode 100644 core/templates/core/macros.jinja create mode 100644 counter/templates/counter/product_list.jinja diff --git a/club/views.py b/club/views.py index 3648065a..437075c2 100644 --- a/club/views.py +++ b/club/views.py @@ -10,14 +10,14 @@ from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin from club.models import Club, Membership from sith.settings import SITH_MAXIMUM_FREE_ROLE, SITH_MAIN_BOARD_GROUP -class ClubListView(CanViewMixin, ListView): +class ClubListView(ListView): """ List the Clubs """ model = Club template_name = 'club/club_list.jinja' -class ClubView(CanViewMixin, DetailView): +class ClubView(DetailView): """ Front page of a Club """ diff --git a/core/migrations/0008_pagerev_revision.py b/core/migrations/0008_pagerev_revision.py new file mode 100644 index 00000000..1707b0ce --- /dev/null +++ b/core/migrations/0008_pagerev_revision.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0007_user_is_superuser'), + ] + + operations = [ + migrations.AddField( + model_name='pagerev', + name='revision', + field=models.IntegerField(default=1, verbose_name='revision'), + preserve_default=False, + ), + ] diff --git a/core/models.py b/core/models.py index 003e3033..a0834330 100644 --- a/core/models.py +++ b/core/models.py @@ -457,6 +457,7 @@ class PageRev(models.Model): is the real content of the page. The content is in PageRev.title and PageRev.content . """ + revision = models.IntegerField(_("revision")) title = models.CharField(_("page title"), max_length=255, blank=True) content = models.TextField(_("page content"), blank=True) date = models.DateTimeField(_('date'), auto_now=True) @@ -488,6 +489,8 @@ class PageRev(models.Model): return object.__getattribute__(self, attr) def save(self, *args, **kwargs): + if self.revision is None: + self.revision = self.page.revisions.all().count() + 1 super(PageRev, self).save(*args, **kwargs) # Don't forget to unlock, otherwise, people will have to wait for the page's timeout self.page.unset_lock() diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 46ba08ab..c9fdbdb5 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -30,6 +30,7 @@ {% trans %}Wiki{% endtrans %} {% trans %}Pages{% endtrans %} {% trans %}Clubs{% endtrans %} + {% trans %}Services{% endtrans %}
diff --git a/core/templates/core/macros.jinja b/core/templates/core/macros.jinja new file mode 100644 index 00000000..84fa1d6c --- /dev/null +++ b/core/templates/core/macros.jinja @@ -0,0 +1,3 @@ +{% macro user_profile_link(user) -%} +{{ user.get_display_name() }} +{%- endmacro %} diff --git a/core/templates/core/page_detail.jinja b/core/templates/core/page_detail.jinja index bd36a3a3..afa5d3ca 100644 --- a/core/templates/core/page_detail.jinja +++ b/core/templates/core/page_detail.jinja @@ -2,7 +2,7 @@ {% block page %} {% if rev %} -

{% trans rev_id=rev.id %}This may not be the last update, you are seeing revision {{ rev_id }}!{% endtrans %}

+

{% trans rev_id=rev.revision %}This may not be the last update, you are seeing revision {{ rev_id }}!{% endtrans %}

{{ rev.title }}

{{ rev.content|markdown }}
{% else %} diff --git a/core/templates/core/page_hist.jinja b/core/templates/core/page_hist.jinja index cc9d0211..2694ba82 100644 --- a/core/templates/core/page_hist.jinja +++ b/core/templates/core/page_hist.jinja @@ -1,18 +1,22 @@ {% extends "core/page.jinja" %} +{% from "core/macros.jinja" import user_profile_link %} + {% block page %} -

{% trans %}Page history{% endtrans %}

+

{% trans %}Page history{% endtrans %}

{% trans page_name=page.name %}You're seeing the history of page "{{ page_name }}"{% endtrans %}

{% endblock %} diff --git a/core/templates/core/user_tools.jinja b/core/templates/core/user_tools.jinja index 7306c11a..d3fc0477 100644 --- a/core/templates/core/user_tools.jinja +++ b/core/templates/core/user_tools.jinja @@ -23,6 +23,7 @@