Commit c62a1ac3 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by chirac

Merge branch 'master' into graph_topo

parents e690292e d27d6705
This diff is collapsed.
......@@ -651,6 +651,10 @@ def control(request):
if control_invoices_form.is_valid():
control_invoices_form.save()
reversion.set_comment("Controle")
messages.success(
request,
_("Your changes have been properly taken into account.")
)
return redirect(reverse('cotisations:control'))
return render(request, 'cotisations/control.html', {
'facture_list': invoice_list,
......
......@@ -541,8 +541,7 @@ class Extension(RevMixin, AclMixin, models.Model):
)
soa = models.ForeignKey(
'SOA',
on_delete=models.CASCADE,
default=SOA.new_default_soa
on_delete=models.CASCADE
)
class Meta:
......
......@@ -189,7 +189,7 @@ def can_change(*targets):
method 'can_change'. See `acl_base_decorator` documentation for further
details.
"""
return acl_base_decorator('can_change', *targets)
return acl_base_decorator('can_change', *targets, on_instance=False)
def can_delete(*targets):
......
......@@ -25,6 +25,7 @@ A set of mixins used all over the project to avoid duplicating code
from reversion import revisions as reversion
from django.utils.functional import cached_property
from django.db import transaction
class RevMixin(object):
......@@ -34,13 +35,16 @@ class RevMixin(object):
def save(self, *args, **kwargs):
""" Creates a version of this object and save it to database """
if self.pk is None:
reversion.set_comment("Création")
with transaction.atomic(), reversion.create_revision():
reversion.set_comment("Création")
return super(RevMixin, self).save(*args, **kwargs)
return super(RevMixin, self).save(*args, **kwargs)
def delete(self, *args, **kwargs):
""" Creates a version of this object and delete it from database """
reversion.set_comment("Suppresion")
return super(RevMixin, self).delete(*args, **kwargs)
with transaction.atomic(), reversion.create_revision():
reversion.set_comment("Suppresion")
return super(RevMixin, self).delete(*args, **kwargs)
class FormRevMixin(object):
......
$(document).ready(function() {
ctrl = false;
alt = false;
});
$(document).keydown(function(event) {
// Update state keys
if (event.which == "17")
ctrl = true;
else if (event.which == "18")
alt = true;
// CTRL+K will focus on the search bar
else if (ctrl && event.which == "75") {
event.stopPropagation();
event.preventDefault();
$("#search-term")[0].focus();
}
// CTRL+L will trigger the login/logout
else if (ctrl && event.which == "76") {
event.stopPropagation();
event.preventDefault();
window.location.href = $("#toggle_login")[0].href;
}
});
$(document).keyup(function(event) {
// Update state keys
if (event.which == "17")
ctrl = false;
else if (event.which == "18")
alt = false;
});
......@@ -50,6 +50,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<script src="/static/js/konami/konami.js"></script>
<script src="/static/js/sapphire.js"> var s=Sapphire(); Konami(s.activate); </script>
<script src="/static/js/bootstrap-tokenfield/bootstrap-tokenfield.js"></script>
<script src="/static/js/shortcuts.js"></script>
<link rel="stylesheet" href="{% static "/css/base.css" %}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ site_name }} : {% block title %}Accueil{% endblock %}</title>
......@@ -74,7 +75,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user-circle"></i> {{request.user.pseudo|slice:":15"}} <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{% url "users:mon-profil" %}"><i class="fa fa-user"></i> Mon profil</a></li>
<li><a href="{% url 'logout' %}"><i class="fa fa-sign-out-alt"></i> Se déconnecter</a></li>
<li><a id="toggle_login" href="{% url 'logout' %}"><i class="fa fa-sign-out-alt"></i> Se déconnecter</a></li>
</ul>
</li>
{% endif %}
......@@ -129,7 +130,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</li>
{% endif %}
<li>
<a href="{% url 'login' %}">
<a id="toggle_login" href="{% url 'login' %}">
<i class="fa fa-sign-in-alt"></i> Login
</a>
</li>
......
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