add basic management of regies (#6702)

This commit is contained in:
Frédéric Péters 2015-03-11 15:41:21 +01:00
parent 180534745c
commit fa837620d7
6 changed files with 131 additions and 1 deletions

34
lingo/manager_views.py Normal file
View File

@ -0,0 +1,34 @@
# lingo - basket and payment system
# Copyright (C) 2015 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.views.generic import CreateView, UpdateView, ListView, DeleteView
from .models import Regie
class RegieListView(ListView):
model = Regie
class RegieCreateView(CreateView):
model = Regie
class RegieUpdateView(UpdateView):
model = Regie
class RegieDeleteView(DeleteView):
model = Regie

View File

@ -0,0 +1,11 @@
{% extends "combo/manager_base.html" %}
{% load i18n %}
{% block appbar %}
<h2>{% trans 'Regies' %}</h2>
{% endblock %}
{% block more-user-links %}
{{ block.super }}
<a href="{% url 'lingo-manager-homepage' %}">{% trans 'Online Payment' %}</a>
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends "combo/manager_base.html" %}
{% load i18n %}
{% block appbar %}
<h2>{{ view.model.get_verbose_name }}</h2>
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{% blocktrans %}Are you sure you want to delete this?{% endblocktrans %}
<div class="buttons">
<button>{% trans 'Confirm Deletion' %}</button>
<a class="cancel" href="{% url 'lingo-manager-homepage' %}">{% trans 'Cancel' %}</a>
</div>
</form>
{% endblock %}

View File

@ -0,0 +1,25 @@
{% extends "lingo/manager_base.html" %}
{% load i18n %}
{% block appbar %}
{% if object.id %}
<h2>{% trans "Edit Regie" %}</h2>
{% else %}
<h2>{% trans "New Regie" %}</h2>
{% endif %}
{% endblock %}
{% block content %}
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<div class="buttons">
<button>{% trans "Save" %}</button>
<a class="cancel" href="{% url 'lingo-manager-homepage' %}">{% trans 'Cancel' %}</a>
{% if object.id %}
<a class="delete" rel="popup" href="{% url 'lingo-manager-regie-delete' pk=object.id %}">{% trans 'Delete' %}</a>
{% endif %}
</div>
</form>
{% endblock %}

View File

@ -0,0 +1,28 @@
{% extends "lingo/manager_base.html" %}
{% load i18n %}
{% block appbar %}
<h2>{% trans 'Regies' %}</h2>
<a rel="popup" href="{% url 'lingo-manager-regie-add' %}">{% trans 'New' %}</a>
{% endblock %}
{% block content %}
{% if object_list %}
<div class="objects-list">
{% for regie in object_list %}
<div>
<a href="{% url 'lingo-manager-regie-edit' pk=regie.id %}">{{ regie.label }}</a> ({{regie.service}})
</div>
{% endfor %}
</div>
{% else %}
<div class="big-msg-info">
{% blocktrans %}
This site doesn't have any regie yet. Click on the "New" button in the top
right of the page to add a first one.
{% endblocktrans %}
</div>
{% endif %}
{% endblock %}

View File

@ -14,9 +14,22 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf.urls import patterns, url
from django.conf.urls import patterns, url, include
from combo.urls_utils import decorated_includes, manager_required
from .views import RegiesApiView, AddBasketItemApiView, PayView, CallbackView
from .manager_views import (RegieListView, RegieCreateView, RegieUpdateView,
RegieDeleteView)
lingo_manager_urls = patterns('lingo.manager_views',
url('^$', RegieListView.as_view(), name='lingo-manager-homepage'),
url('^regies/add/$', RegieCreateView.as_view(), name='lingo-manager-regie-add'),
url('^regies/(?P<pk>\w+)/edit$', RegieUpdateView.as_view(),
name='lingo-manager-regie-edit'),
url('^regies/(?P<pk>\w+)/delete$', RegieDeleteView.as_view(),
name='lingo-manager-regie-delete'),
)
urlpatterns = patterns('',
url('^api/lingo/regies$', RegiesApiView.as_view(), name='api-regies'),
@ -24,4 +37,6 @@ urlpatterns = patterns('',
name='api-add-basket-item'),
url('^lingo/pay$', PayView.as_view(), name='lingo-pay'),
url(r'^lingo/callback/(?P<regie_pk>\w+)/$', CallbackView.as_view(), name='lingo-callback'),
url(r'^manage/lingo/', decorated_includes(manager_required,
include(lingo_manager_urls))),
)