make it possible to bypass validation steps (#13936)
This commit is contained in:
parent
2482143850
commit
37b1dd0074
|
@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
|
|||
|
||||
import os
|
||||
from django.conf import global_settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
@ -172,6 +173,12 @@ VALIDATION_STEPS = {
|
|||
'mail': ['done-qualif', 'done-dgs', 'done-dga'],
|
||||
}
|
||||
|
||||
VALIDATION_STEP_LABELS = {
|
||||
'done-qualif': _('Send to DGS'),
|
||||
'done-dgs': _('Send to DGA'),
|
||||
'done-dga': _('Send to service'),
|
||||
}
|
||||
|
||||
# mapping of channel to group/role *names*
|
||||
CHANNEL_ROLES = {
|
||||
'mail': [],
|
||||
|
|
|
@ -163,12 +163,16 @@ div#content .cell.qualif form button.add {
|
|||
right: 1ex;
|
||||
}
|
||||
|
||||
div#content .cell.qualif form button.done {
|
||||
div#content .cell.qualif form .done {
|
||||
position: absolute;
|
||||
right: 1ex;
|
||||
bottom: 1ex;
|
||||
}
|
||||
|
||||
div#content .cell.qualif form .done button {
|
||||
position: static;
|
||||
}
|
||||
|
||||
div#content .cell.qualif .select2-container,
|
||||
div#content .cell.qualif select {
|
||||
width: 98%;
|
||||
|
|
|
@ -33,7 +33,15 @@
|
|||
{% endif %}
|
||||
|
||||
{% if associations|length %}
|
||||
<button class="done" data-action-url="{% url 'qualif-done' %}">{% trans 'Submit' %}</button>
|
||||
<div class="done">
|
||||
{% if validation_steps %}
|
||||
{% for validation_step in validation_steps %}
|
||||
<button class="done" data-action-url="{% url 'qualif-done' %}?step={{validation_step.id}}">{{validation_step.label}}</button>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<button class="done" data-action-url="{% url 'qualif-done' %}">{% trans 'Submit' %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endif %}
|
||||
|
|
|
@ -86,6 +86,9 @@ class Qualification(TemplateView):
|
|||
context['associations'] = Association.objects.filter(
|
||||
source_type=ContentType.objects.get(id=self.request.GET['source_type']),
|
||||
source_pk=self.request.GET['source_pk']).order_by('id')
|
||||
validation_steps = settings.VALIDATION_STEPS.get(source_type.model.lower()) or []
|
||||
context['validation_steps'] = [
|
||||
{'id': x, 'label': settings.VALIDATION_STEP_LABELS[x]} for x in validation_steps]
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
@ -159,11 +162,14 @@ def qualification_done(request):
|
|||
id=request.POST['source_type']).model_class()
|
||||
source_object = source_class.objects.get(id=request.POST['source_pk'])
|
||||
validation_steps = settings.VALIDATION_STEPS.get(source_class.__name__.lower())
|
||||
if source_object.status:
|
||||
source_object.status = validation_steps[
|
||||
validation_steps.index(source_object.status)+1]
|
||||
if request.GET.get('step'):
|
||||
source_object.status = validation_steps[validation_steps.index(request.GET.get('step'))]
|
||||
else:
|
||||
source_object.status = validation_steps[0]
|
||||
if source_object.status:
|
||||
source_object.status = validation_steps[
|
||||
validation_steps.index(source_object.status)+1]
|
||||
else:
|
||||
source_object.status = validation_steps[0]
|
||||
if source_object.status == validation_steps[-1]:
|
||||
for association in Association.objects.filter(
|
||||
source_type=request.POST['source_type'],
|
||||
|
|
Loading…
Reference in New Issue