Commit 5f9ec9a2 authored by Krophil's avatar Krophil

Merge branch 'Tresorerie' of https://ae-dev.utbm.fr/ae/Sith into Tresorerie

parents ebe76c83 0bf457de
......@@ -56,6 +56,12 @@ Finally, when building a class based view, which is highly advised, you just hav
CanEditMixin, or CanViewMixin, which are located in core.views. Your view will then be protected using either the
appropriate group fields, or the right method to check user permissions.
#### Counting the number of line of code
```
# apt install cloc
$ cloc --exclude-dir=doc,env .
```
......@@ -5,7 +5,9 @@
{% endblock %}
{% block content %}
{% if user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) or user.is_root %}
<p><a href="{{ url('accounting:co_new') }}">{% trans %}Create new company{% endtrans %}</a></p>
{% endif %}
</br>
<table>
......
......@@ -736,9 +736,9 @@ class Page(models.Model):
name = models.CharField(_('page unix name'), max_length=30,
validators=[
validators.RegexValidator(
r'^[\w.+-]+$',
r'^[A-z.+-]+$',
_('Enter a valid page name. This value may contain only '
'letters, numbers ' 'and ./+/-/_ characters.')
'unaccented letters, numbers ' 'and ./+/-/_ characters.')
),
],
blank=False)
......@@ -846,6 +846,14 @@ class Page(models.Model):
p.set_lock_recursive(user)
self.set_lock(user)
def unset_lock_recursive(self):
"""
Unlocks recursively all the child pages
"""
for p in self.children.all():
p.unset_lock_recursive()
self.unset_lock()
def unset_lock(self):
"""Always try to unlock, even if there is no lock"""
self.lock_user = None
......@@ -886,6 +894,16 @@ class Page(models.Model):
except:
return self.name
def delete(self):
self.unset_lock_recursive()
self.set_lock_recursive(User.objects.get(id=0))
for child in self.children.all():
child.parent = self.parent
child.save()
child.unset_lock_recursive()
super(Page, self).delete()
class PageRev(models.Model):
"""
This is the true content of the page.
......
......@@ -23,6 +23,7 @@ function make_preview() {
<p><input type="button" value="{% trans %}Preview{% endtrans %}" onclick="javascript:make_preview();" /></p>
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
</form>
<a href="{{ url('core:page_delete', page_id=page.id)}}">{% trans %}Delete{% endtrans %}</a>
<div id="preview">
</div>
{% endblock %}
......
......@@ -61,6 +61,7 @@ urlpatterns = [
# Page views
url(r'^page/$', PageListView.as_view(), name='page_list'),
url(r'^page/create$', PageCreateView.as_view(), name='page_new'),
url(r'^page/(?P<page_id>[0-9]*)/delete$', PageDeleteView.as_view(), name='page_delete'),
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/edit$', PageEditView.as_view(), name='page_edit'),
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/prop$', PagePropView.as_view(), name='page_prop'),
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/hist$', PageHistView.as_view(), name='page_hist'),
......
# This file contains all the views that concern the page model
from django.shortcuts import render, redirect, get_object_or_404
from django.core.urlresolvers import reverse_lazy
from django.views.generic import ListView, DetailView
from django.views.generic.edit import UpdateView, CreateView
from django.views.generic.edit import UpdateView, CreateView, DeleteView
from django.contrib.auth.decorators import login_required, permission_required
from django.utils.decorators import method_decorator
from django.forms.models import modelform_factory
......@@ -159,3 +160,11 @@ class PageEditView(CanEditMixin, UpdateView):
form.instance = new_rev
return super(PageEditView, self).form_valid(form)
class PageDeleteView(CanEditPropMixin, DeleteView):
model = Page
template_name = 'core/delete_confirm.jinja'
pk_url_kwarg = 'page_id'
def get_success_url(self, **kwargs):
return reverse_lazy('core:page_list')
......@@ -688,26 +688,26 @@ class CashRegisterSummaryForm(forms.Form):
"""
Provide the cash summary form
"""
ten_cents = forms.IntegerField(label=_("10 cents"), required=False)
twenty_cents = forms.IntegerField(label=_("20 cents"), required=False)
fifty_cents = forms.IntegerField(label=_("50 cents"), required=False)
one_euro = forms.IntegerField(label=_("1 euro"), required=False)
two_euros = forms.IntegerField(label=_("2 euros"), required=False)
five_euros = forms.IntegerField(label=_("5 euros"), required=False)
ten_euros = forms.IntegerField(label=_("10 euros"), required=False)
twenty_euros = forms.IntegerField(label=_("20 euros"), required=False)
fifty_euros = forms.IntegerField(label=_("50 euros"), required=False)
hundred_euros = forms.IntegerField(label=_("100 euros"), required=False)
check_1_value = forms.DecimalField(label=_("Check amount"), required=False)
check_1_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
check_2_value = forms.DecimalField(label=_("Check amount"), required=False)
check_2_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
check_3_value = forms.DecimalField(label=_("Check amount"), required=False)
check_3_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
check_4_value = forms.DecimalField(label=_("Check amount"), required=False)
check_4_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
check_5_value = forms.DecimalField(label=_("Check amount"), required=False)
check_5_quantity = forms.IntegerField(label=_("Check quantity"), required=False)
ten_cents = forms.IntegerField(label=_("10 cents"), required=False, min_value=0)
twenty_cents = forms.IntegerField(label=_("20 cents"), required=False, min_value=0)
fifty_cents = forms.IntegerField(label=_("50 cents"), required=False, min_value=0)
one_euro = forms.IntegerField(label=_("1 euro"), required=False, min_value=0)
two_euros = forms.IntegerField(label=_("2 euros"), required=False, min_value=0)
five_euros = forms.IntegerField(label=_("5 euros"), required=False, min_value=0)
ten_euros = forms.IntegerField(label=_("10 euros"), required=False, min_value=0)
twenty_euros = forms.IntegerField(label=_("20 euros"), required=False, min_value=0)
fifty_euros = forms.IntegerField(label=_("50 euros"), required=False, min_value=0)
hundred_euros = forms.IntegerField(label=_("100 euros"), required=False, min_value=0)
check_1_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
check_1_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
check_2_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
check_2_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
check_3_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
check_3_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
check_4_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
check_4_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
check_5_value = forms.DecimalField(label=_("Check amount"), required=False, min_value=0)
check_5_quantity = forms.IntegerField(label=_("Check quantity"), required=False, min_value=0)
comment = forms.CharField(label=_("Comment"), required=False)
emptied = forms.BooleanField(label=_("Emptied"), required=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment