phone: use a qualification screen that doesn't require validations
This commit is contained in:
parent
380c892456
commit
5e455ba44f
|
@ -164,8 +164,9 @@ HAYSTACK_CONNECTIONS = {
|
|||
|
||||
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
|
||||
|
||||
# VALIDATION_STEPS = ['done-qualif']
|
||||
VALIDATION_STEPS = ['done-qualif', 'done-dgs', 'done-dga']
|
||||
VALIDATION_STEPS = {
|
||||
'mail': ['done-qualif', 'done-dgs', 'done-dga'],
|
||||
}
|
||||
|
||||
|
||||
local_settings_file = os.environ.get('WELCO_SETTINGS_FILE',
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{% load i18n %}
|
||||
|
||||
<p>
|
||||
{{object.caller}}
|
||||
</p>
|
|
@ -199,17 +199,22 @@ form#kb-search {
|
|||
margin: 0 1ex;
|
||||
}
|
||||
|
||||
ul.formdatas,
|
||||
ul.result {
|
||||
margin: 2ex 0 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.qualif ul.formdatas li,
|
||||
ul.result li {
|
||||
margin: -1px 1em 0 2px;
|
||||
list-style: none;
|
||||
border: 1px solid #ccc;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
ul.formdatas li a,
|
||||
ul.result li a {
|
||||
display: block;
|
||||
padding: 1ex;
|
||||
|
@ -217,10 +222,17 @@ ul.result li a {
|
|||
border-bottom: 0;
|
||||
}
|
||||
|
||||
ul.formdatas li a:hover,
|
||||
ul.result li a:hover {
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
ul.formdatas a.remove {
|
||||
position: absolute;
|
||||
right: 1ex;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
ul.result li a span.more {
|
||||
display: block;
|
||||
color: #666;
|
||||
|
|
|
@ -404,4 +404,22 @@ $(function() {
|
|||
window.setTimeout(check_calls, 1000);
|
||||
}
|
||||
|
||||
$('.qualif').delegate('a.create-formdata', 'click', function() {
|
||||
$.ajax({url: $(this).data('action-url'),
|
||||
data: {},
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (data.result == 'ok') {
|
||||
window.open(data.url, '_blank');
|
||||
refresh_bottom_cells();
|
||||
} else {
|
||||
/* TODO: display error notification */
|
||||
}
|
||||
},
|
||||
error: function(error) { console.log(':(', error); }
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
{% load i18n %}
|
||||
<div>
|
||||
{% if source_pk %}
|
||||
<form>
|
||||
{% if associations|length %}
|
||||
<ul class="formdatas">
|
||||
{% for association in associations %}
|
||||
<li>
|
||||
{% if association.formdata_id %}
|
||||
<a href="{{association.formdata_url}}" target="_blank">
|
||||
{{association.formdef_name}}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="#"
|
||||
class="create-formdata"
|
||||
data-action-url="{% url 'ajax-create-formdata' pk=association.id %}"
|
||||
data-association-pk="{{association.id}}">{{association.formdef_name}}</a>
|
||||
<a class="remove" href="{% url 'ajax-remove-association' pk=association.id %}">✖</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><a href="#" class="plus">{% trans 'Add another' %}</a></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<div class="add-formdef-reference" {% if associations|length %}style="display: none"{% endif %}>
|
||||
<div>
|
||||
{{form.formdef_reference}}
|
||||
</div>
|
||||
<button class="add">{% trans 'Add' %}</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -29,6 +29,8 @@ urlpatterns = patterns('',
|
|||
url(r'^ajax/qualification-done$', 'welco.views.qualification_done', name='qualif-done'),
|
||||
url(r'^ajax/remove-association/(?P<pk>\w+)$',
|
||||
'welco.views.remove_association', name='ajax-remove-association'),
|
||||
url(r'^ajax/create-formdata/(?P<pk>\w+)$',
|
||||
'welco.views.create_formdata', name='ajax-create-formdata'),
|
||||
|
||||
url(r'^ajax/kb$', 'welco.kb.views.zone', name='kb-zone'),
|
||||
url(r'^kb/$', 'welco.kb.views.page_list', name='kb-home'),
|
||||
|
|
|
@ -65,7 +65,13 @@ def logout(request, next_page=None):
|
|||
|
||||
|
||||
class Qualification(TemplateView):
|
||||
template_name = 'welco/qualification.html'
|
||||
def get_template_names(self):
|
||||
source_type = ContentType.objects.get(id=self.request.GET['source_type'])
|
||||
validation_steps = settings.VALIDATION_STEPS.get(source_type.model.lower())
|
||||
if validation_steps:
|
||||
return ['welco/qualification.html']
|
||||
else:
|
||||
return ['welco/qualification_no_validation.html']
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(Qualification, self).get_context_data(**kwargs)
|
||||
|
@ -73,11 +79,12 @@ class Qualification(TemplateView):
|
|||
context['source_type'] = self.request.GET['source_type']
|
||||
source_type = ContentType.objects.get(id=self.request.GET['source_type'])
|
||||
context['source_type_name'] = source_type.model
|
||||
validation_steps = settings.VALIDATION_STEPS.get(source_type.model.lower())
|
||||
context['source_pk'] = self.request.GET['source_pk']
|
||||
if self.request.GET.get('source_pk'):
|
||||
context['associations'] = Association.objects.filter(
|
||||
source_type=ContentType.objects.get(id=self.request.GET['source_type']),
|
||||
source_pk=self.request.GET['source_pk'])
|
||||
source_pk=self.request.GET['source_pk']).order_by('id')
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
@ -122,12 +129,13 @@ def qualification_done(request):
|
|||
source_class = ContentType.objects.get(
|
||||
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 = settings.VALIDATION_STEPS[
|
||||
settings.VALIDATION_STEPS.index(source_object.status)+1]
|
||||
source_object.status = validation_steps[
|
||||
validation_steps.index(source_object.status)+1]
|
||||
else:
|
||||
source_object.status = settings.VALIDATION_STEPS[0]
|
||||
if source_object.status == settings.VALIDATION_STEPS[-1]:
|
||||
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'],
|
||||
source_pk=request.POST['source_pk']):
|
||||
|
@ -159,6 +167,18 @@ def remove_association(request, *args, **kwargs):
|
|||
Association.objects.filter(id=kwargs.get('pk')).delete()
|
||||
return HttpResponseRedirect(resolve_url('home'))
|
||||
|
||||
@login_required
|
||||
@csrf_exempt
|
||||
def create_formdata(request, *args, **kwargs):
|
||||
response = HttpResponse(content_type='application/json')
|
||||
if request.method != 'POST':
|
||||
json.dump({'err': 1}, response)
|
||||
else:
|
||||
qualif = Association.objects.get(id=kwargs.get('pk'))
|
||||
qualif.push(request)
|
||||
json.dump({'result': 'ok', 'url': qualif.formdata_url}, response)
|
||||
return response
|
||||
|
||||
@login_required
|
||||
def menu_json(request):
|
||||
response = HttpResponse(content_type='application/json')
|
||||
|
|
Loading…
Reference in New Issue