Add homepage view for validation requests (fixes #24339)
Validation request view is also modified to allow viewing validated requests.
This commit is contained in:
parent
c978f80921
commit
de92f180a7
|
@ -691,6 +691,6 @@ class AppConfig(django.apps.AppConfig):
|
|||
def a2_hook_manager_homepage_entries(self, view):
|
||||
return {
|
||||
'label': 'Validation des comptes',
|
||||
'href': reverse_lazy('cut-manager-user-next-validation'),
|
||||
'href': reverse_lazy('cut-manager-user-validation'),
|
||||
'class': 'icon-management',
|
||||
}
|
||||
|
|
|
@ -148,16 +148,29 @@ class ValidationRequest(models.Model):
|
|||
def get_taken_by(self):
|
||||
return self.taken_by if self.is_taken else None
|
||||
|
||||
@property
|
||||
def human_status(self):
|
||||
if self.status == self.STATUS_REFUSED:
|
||||
return u'refusé par %s' % self.refused_by.get_full_name()
|
||||
return u'refusé'
|
||||
elif self.status == self.STATUS_ACCEPTED:
|
||||
return u'accepté par %s' % self.validated_by.get_full_name()
|
||||
return u'accepté'
|
||||
elif self.status == self.STATUS_RECEIVED:
|
||||
if self.is_taken:
|
||||
return u'en traitement par %s' % self.taken_by.get_full_name()
|
||||
return u'en traitement'
|
||||
else:
|
||||
return u'reçu'
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def human_status_who(self):
|
||||
if self.status == self.STATUS_REFUSED:
|
||||
return self.validated_by
|
||||
elif self.status == self.STATUS_ACCEPTED:
|
||||
return self.validated_by
|
||||
elif self.status == self.STATUS_RECEIVED:
|
||||
if self.is_taken:
|
||||
return self.taken_by
|
||||
|
||||
class Meta:
|
||||
verbose_name = u'Requête de validation'
|
||||
|
|
|
@ -19,13 +19,13 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
import django_tables2 as tables
|
||||
|
||||
from .models import Journal
|
||||
from . import models
|
||||
|
||||
|
||||
class UserActionsTable(tables.Table):
|
||||
class Meta:
|
||||
attrs = {'class': 'main'}
|
||||
model = Journal
|
||||
model = models.Journal
|
||||
exclude = ['id', 'actor']
|
||||
empty_text = _('None')
|
||||
|
||||
|
@ -33,6 +33,40 @@ class UserActionsTable(tables.Table):
|
|||
class UserModificationsTable(tables.Table):
|
||||
class Meta:
|
||||
attrs = {'class': 'main'}
|
||||
model = Journal
|
||||
model = models.Journal
|
||||
exclude = ['id', 'subject']
|
||||
empty_text = _('None')
|
||||
|
||||
|
||||
class ValidationTable(tables.Table):
|
||||
pk = tables.LinkColumn(
|
||||
viewname='cut-manager-user-validation',
|
||||
kwargs={'pk': tables.A('pk')},
|
||||
verbose_name='Identifiant')
|
||||
user = tables.LinkColumn(
|
||||
viewname='a2-manager-user-detail',
|
||||
kwargs={'pk': tables.A('user.pk')},
|
||||
accessor='user.get_full_name')
|
||||
origin = tables.Column(
|
||||
verbose_name='Service demandeur')
|
||||
human_status = tables.Column(
|
||||
verbose_name='Statut')
|
||||
human_status_who = tables.LinkColumn(
|
||||
verbose_name='Agent',
|
||||
viewname='a2-manager-user-detail',
|
||||
accessor='human_status_who.get_full_name',
|
||||
kwargs={'pk': tables.A('human_status_who.pk')})
|
||||
|
||||
class Meta:
|
||||
model = models.ValidationRequest
|
||||
attrs = {'class': 'main', 'id': 'validation-request-table'}
|
||||
fields = (
|
||||
'pk',
|
||||
'created',
|
||||
'user',
|
||||
'origin',
|
||||
'external_id',
|
||||
'validated',
|
||||
'human_status',
|
||||
)
|
||||
empty_text = _('None')
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'a2-manager-users' %}{% if multiple_ou and object.ou %}?search-ou={{ object.ou.pk }}{% endif %}">{% trans 'Users' %}{% if multiple_ou and object.ou %} : {{ object.ou }}{% endif %}</a>
|
||||
<a href="{% url 'cut-manager-user-validation' %}">Validation d'identité</a>
|
||||
<a href="{% url 'a2-manager-user-detail' pk=object.pk %}">{{ object.get_full_name }}</a>
|
||||
<a href="#">Validation d'identité</a>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@ -68,13 +67,15 @@ $('body').on('click', 'img.popup-image', function (event) {
|
|||
{% endblock %}
|
||||
|
||||
{% block buttons %}
|
||||
<div class="buttons">
|
||||
<button name="validate">Valider</button>
|
||||
</div>
|
||||
<h4>Refus</h4>
|
||||
{{ validation_form.as_p }}
|
||||
<div class="buttons">
|
||||
<button name="refuse">Refuser</button>
|
||||
<button style="float: right; margin-right: 30px" name="next">Suivant</button>
|
||||
</div>
|
||||
{% if not validation_request.validated %}
|
||||
<div class="buttons">
|
||||
<button name="validate">Valider</button>
|
||||
</div>
|
||||
<h4>Refus</h4>
|
||||
{{ validation_form.as_p }}
|
||||
<div class="buttons">
|
||||
<button name="refuse">Refuser</button>
|
||||
<button style="float: right; margin-right: 30px" name="next">Suivant</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
{% extends "authentic2/manager/base.html" %}
|
||||
{% load i18n staticfiles django_tables2 %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>Validation d'identité
|
||||
</h2>
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="#">Validation d'identité</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
<aside id="sidebar">
|
||||
<p>
|
||||
<h2>Filtres</h2>
|
||||
{% if request.GET.all %}
|
||||
<a href="?">Uniquement les demandes reçues</a>
|
||||
{% else %}
|
||||
<a href="?all=1">Toutes les demandes</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
<a href="{% url 'cut-manager-user-next-validation' %}" class="button">Traiter la prochaine demande</a>
|
||||
</p>
|
||||
</aside>
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<style>
|
||||
#validation-request-table tbody .human_status {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
{% with row_link=1 %}
|
||||
{% render_table table "authentic2/manager/table.html" %}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
|
@ -35,6 +35,8 @@ urlpatterns = required(
|
|||
name='cut-manager-user-actions-journal'),
|
||||
url('^manage/users/(?P<pk>\d+)/modifications-journal/$', views.user_modifications_journal,
|
||||
name='cut-manager-user-modifications-journal'),
|
||||
url('^manage/validation/$', views.validation_homepage,
|
||||
name='cut-manager-user-validation'),
|
||||
url('^manage/validation/next/$', views.next_validation,
|
||||
name='cut-manager-user-next-validation'),
|
||||
url('^manage/validation/(?P<pk>\d+)/$', views.validation,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.views.generic.base import TemplateView
|
||||
|
@ -25,13 +26,13 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404
|
|||
from django.db.transaction import atomic
|
||||
|
||||
from authentic2.views import EditProfile
|
||||
from authentic2.manager.views import SimpleSubTableView
|
||||
from authentic2.manager.views import SimpleSubTableView, BaseTableView
|
||||
from authentic2.manager.user_views import UserEditView, UserDetailView
|
||||
from authentic2 import hooks
|
||||
from authentic2.utils import redirect
|
||||
|
||||
from .custom_settings import CORE_ATTRIBUTES
|
||||
from . import tables, models, forms
|
||||
from . import tables, models, forms, tables
|
||||
|
||||
|
||||
class EditCoreView(EditProfile):
|
||||
|
@ -192,7 +193,7 @@ class Validation(UserEditCoreView):
|
|||
permissions = ['custom_user.cut_validate_user']
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
qs = models.ValidationRequest.objects.received()
|
||||
qs = models.ValidationRequest.objects.all()
|
||||
self.validation_request = super(Validation, self).get_object(queryset=qs)
|
||||
return self.validation_request.user
|
||||
|
||||
|
@ -270,3 +271,20 @@ def validation_attachment(request, pk):
|
|||
raise PermissionDenied
|
||||
attachment = models.ValidationRequestAttachment.objects.get(pk=pk)
|
||||
return HttpResponse(attachment.image, content_type='image/jpeg')
|
||||
|
||||
|
||||
class ValidationHomepage(BaseTableView):
|
||||
template_name = 'authentic2/cut_manager_user_validations.html'
|
||||
model = models.ValidationRequest
|
||||
table_class = tables.ValidationTable
|
||||
permissions = ['custom_user.cut_validate_user']
|
||||
title = _('Validation requests')
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super(ValidationHomepage, self).get_queryset()
|
||||
if 'all' not in self.request.GET:
|
||||
qs = qs.filter(status=models.ValidationRequest.STATUS_RECEIVED)
|
||||
qs = qs.prefetch_related('origin').select_related()
|
||||
return qs
|
||||
|
||||
validation_homepage = ValidationHomepage.as_view()
|
||||
|
|
Loading…
Reference in New Issue