mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add product management views
This commit is contained in:
20
core/migrations/0008_pagerev_revision.py
Normal file
20
core/migrations/0008_pagerev_revision.py
Normal file
@ -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,
|
||||
),
|
||||
]
|
@ -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()
|
||||
|
@ -30,6 +30,7 @@
|
||||
<a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
|
||||
<a href="{{ url('core:page_list') }}">{% trans %}Pages{% endtrans %}</a>
|
||||
<a href="{{ url('club:club_list') }}">{% trans %}Clubs{% endtrans %}</a>
|
||||
<a href="{{ url('core:page', "Services") }}">{% trans %}Services{% endtrans %}</a>
|
||||
</nav>
|
||||
|
||||
<div id="content">
|
||||
|
3
core/templates/core/macros.jinja
Normal file
3
core/templates/core/macros.jinja
Normal file
@ -0,0 +1,3 @@
|
||||
{% macro user_profile_link(user) -%}
|
||||
<a href="{{ url("core:user_profile", user_id=user.id) }}">{{ user.get_display_name() }}</a>
|
||||
{%- endmacro %}
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% block page %}
|
||||
{% if rev %}
|
||||
<h4>{% trans rev_id=rev.id %}This may not be the last update, you are seeing revision {{ rev_id }}!{% endtrans %}</h4>
|
||||
<h4>{% trans rev_id=rev.revision %}This may not be the last update, you are seeing revision {{ rev_id }}!{% endtrans %}</h4>
|
||||
<h3>{{ rev.title }}</h3>
|
||||
<div class="page_content">{{ rev.content|markdown }}</div>
|
||||
{% else %}
|
||||
|
@ -1,18 +1,22 @@
|
||||
{% extends "core/page.jinja" %}
|
||||
|
||||
{% from "core/macros.jinja" import user_profile_link %}
|
||||
|
||||
{% block page %}
|
||||
<h3>{% trans %}Page history{% endtrans %}</h3>
|
||||
<h3>{% trans %}Page history{% endtrans %}</h3>
|
||||
<p>{% trans page_name=page.name %}You're seeing the history of page "{{ page_name }}"{% endtrans %}</p>
|
||||
<ul>
|
||||
{% for r in (page.revisions.all()|sort(attribute='date', reverse=True)) %}
|
||||
{% for r in (page.revisions.all()|sort(attribute='date', reverse=True)) %}
|
||||
{% if loop.index < 2 %}
|
||||
<li><a href="{{ url('core:page', page_name=page.get_full_name()) }}">
|
||||
last - {{ page.revisions.last().author }} - {{ page.revisions.last().date|date('Y-m-d H:i') }}</a></li>
|
||||
<li><a href="{{ url('core:page', page_name=page.get_full_name()) }}">{% trans %}last{% endtrans %}</a> -
|
||||
{{ user_profile_link(page.revisions.last().author) }} -
|
||||
{{ page.revisions.last().date|localtime|date(DATETIME_FORMAT) }} {{ page.revisions.last().date|localtime|time(DATETIME_FORMAT) }}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ url('core:page_rev', page_name=page.get_full_name(), rev=r['id']) }}">
|
||||
{{ r['author'] }} - {{ r['date']|date('Y-m-d H:i') }}</a></li>
|
||||
<li><a href="{{ url('core:page_rev', page_name=page.get_full_name(), rev=r['id']) }}">{{ r.revision }}</a> -
|
||||
{{ user_profile_link(r.author) }} -
|
||||
{{ page.revisions.last().date|localtime|date(DATETIME_FORMAT) }} {{ page.revisions.last().date|localtime|time(DATETIME_FORMAT) }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
<ul>
|
||||
{% if user.is_in_group(settings.SITH_GROUPS['counter-admin']['name']) or user.is_in_group(settings.SITH_GROUPS['root']['name']) %}
|
||||
<li><a href="{{ url('counter:admin_list') }}">{% trans %}General counters management{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('counter:product_list') }}">{% trans %}General products management{% endtrans %}</a></li>
|
||||
{% endif %}
|
||||
{% for b in settings.SITH_COUNTER_BARS %}
|
||||
{% if user.is_in_group(b[1]+" admin") %}
|
||||
|
Reference in New Issue
Block a user