add start of a phone call view

This commit is contained in:
Frédéric Péters 2015-09-24 15:15:10 +02:00
parent bda5855d0e
commit ee70113a47
12 changed files with 162 additions and 14 deletions

View File

@ -9,6 +9,7 @@ recursive-include welco/sources/mail/static *.css *.js *.ico *.gif *.png *.jpg
recursive-include welco/templates *.html recursive-include welco/templates *.html
recursive-include welco/kb/templates *.html recursive-include welco/kb/templates *.html
recursive-include welco/contacts/templates *.html recursive-include welco/contacts/templates *.html
recursive-include welco/sources/phone/templates *.html
recursive-include welco/sources/mail/templates *.html recursive-include welco/sources/mail/templates *.html
recursive-include welco/contrib/alfortville/templates *.html recursive-include welco/contrib/alfortville/templates *.html

View File

@ -43,6 +43,7 @@ INSTALLED_APPS = (
'haystack', 'haystack',
'reversion', 'reversion',
'welco.sources.mail', 'welco.sources.mail',
'welco.sources.phone',
'welco.qualif', 'welco.qualif',
'welco.kb', 'welco.kb',
'welco.contacts', 'welco.contacts',

View File

@ -50,6 +50,8 @@ class Feeder(TemplateView):
feeder = csrf_exempt(Feeder.as_view()) feeder = csrf_exempt(Feeder.as_view())
class Home(object): class Home(object):
source_key = 'mail'
def __init__(self, request): def __init__(self, request):
self.request = request self.request = request

View File

View File

@ -0,0 +1,49 @@
# welco - multichannel request processing
# Copyright (C) 2015 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import subprocess
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _
class PhoneCall(models.Model):
class Meta:
verbose_name = _('Phone Call')
number = models.CharField(_('Number'), max_length=20)
creation_timestamp = models.DateTimeField(auto_now_add=True)
last_update_timestamp = models.DateTimeField(auto_now=True)
@classmethod
def get_qualification_form_class(cls):
return None
def get_qualification_form(self):
return None
@classmethod
def get_qualification_form_submit_url(cls):
return reverse('qualif-phone-save')
def get_source_context(self, request):
return {
'channel': 'phone',
}

View File

@ -0,0 +1,34 @@
{% load i18n %}
<h2>{% trans 'Phone Call' %}</h2>
<div data-source-type="{{ source_type.id }}">
<h1>{% trans 'Current Call:' %} <strong>01 02 03 04 05</strong></h1>
<h3>{% trans 'Past Calls' %}</h3>
<ul>
<li>16 juillet 2015 11:23:21</li>
<li>15 juillet 2015 16:36:42</li>
</ul>
<script>
$(function() {
$('.cell.qualif').each(function(idx, zone) {
var source_type = $('div.source div[data-source-type]').data('source-type');
var source_pk = $('div.source .active[data-source-pk]').data('source-pk');
$.ajax({url: $(zone).data('zone-url'),
data: {source_type: source_type,
source_pk: source_pk},
async: true,
dataType: 'html',
success: function(data) {
$(zone).find('> div').replaceWith(data);
$(zone).find('select').select2();
$(zone).removeClass('has-page-displayed');
},
error: function(error) { console.log(':(', error); }
});
});
});
</script>
</div>

View File

@ -0,0 +1,33 @@
# welco - multichannel request processing
# Copyright (C) 2015 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django import template
from django.contrib.contenttypes.models import ContentType
from django.template import RequestContext
from .models import PhoneCall
class Home(object):
source_key = 'phone'
def __init__(self, request):
self.request = request
def render(self):
context = RequestContext(self.request)
context['source_type'] = ContentType.objects.get_for_model(PhoneCall)
tmpl = template.loader.get_template('welco/phone_home.html')
return tmpl.render(context)

View File

@ -40,6 +40,12 @@ body.welco-home div#content {
position: relative; position: relative;
} }
.source-phone .cell,
.source-phone .cell.top {
width: 50%;
height: 50%;
}
div#content .cell h2 { div#content .cell h2 {
font-size: 100%; font-size: 100%;
padding-left: 1ex; padding-left: 1ex;
@ -54,7 +60,7 @@ div#content .cell.document iframe {
border: none; border: none;
} }
div#content .cell.document > div { div#content .source-mail .cell.document > div {
display: flex; display: flex;
height: calc(100% - 3em); height: calc(100% - 3em);
} }
@ -157,6 +163,7 @@ form#kb-search {
margin-bottom: 2em; margin-bottom: 2em;
} }
.contacts div.search input,
.kb div.search input { .kb div.search input {
margin: 0 1ex; margin: 0 1ex;
} }
@ -302,3 +309,12 @@ button#create-new-contact {
.contacts.has-contact-displayed .search { .contacts.has-contact-displayed .search {
display: none; display: none;
} }
.source-phone .source h1 {
font-weight: normal;
padding-left: 1ex;
}
.source-phone .source h3 {
padding-left: 1ex;
}

View File

@ -4,7 +4,7 @@
{% block bodyargs %}class="welco-home"{% endblock %} {% block bodyargs %}class="welco-home"{% endblock %}
{% block content %} {% block content %}
<div class="all"> <div class="all source-{{ source.source_key }}">
<div class="cell document source top"> <div class="cell document source top">
{{ source.render }} {{ source.render }}
</div> </div>

View File

@ -2,8 +2,10 @@
<div> <div>
<form> <form>
<div class="qualif-source"> <div class="qualif-source">
{{source_form.as_p}} {% if source_form %}
<button data-action-url="{{source_form_url}}" class="save"></button> {{source_form.as_p}}
<button data-action-url="{{source_form_url}}" class="save"></button>
{% endif %}
</div> </div>
{% if association %} {% if association %}

View File

@ -22,6 +22,7 @@ from . import apps
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^$', 'welco.views.home', name='home'), url(r'^$', 'welco.views.home', name='home'),
url(r'^phone/$', 'welco.views.home_phone', name='home-phone'),
url(r'^ajax/qualification$', 'welco.views.qualification', name='qualif-zone'), url(r'^ajax/qualification$', 'welco.views.qualification', name='qualif-zone'),
url(r'^ajax/qualification-done$', 'welco.views.qualification_done', name='qualif-done'), url(r'^ajax/qualification-done$', 'welco.views.qualification_done', name='qualif-done'),

View File

@ -33,6 +33,7 @@ except ImportError:
get_idps = lambda: [] get_idps = lambda: []
from sources.mail.views import Home as MailHome from sources.mail.views import Home as MailHome
from sources.phone.views import Home as PhoneHome
from .qualif.models import Association, FormdefReference from .qualif.models import Association, FormdefReference
from .kb.views import HomeZone as KbHomeZone from .kb.views import HomeZone as KbHomeZone
from .contacts.views import HomeZone as ContactsHomeZone from .contacts.views import HomeZone as ContactsHomeZone
@ -65,15 +66,16 @@ class Qualification(TemplateView):
context = super(Qualification, self).get_context_data(**kwargs) context = super(Qualification, self).get_context_data(**kwargs)
context['form'] = QualificationForm() context['form'] = QualificationForm()
source_type = ContentType.objects.get(id=self.request.GET['source_type']) source_type = ContentType.objects.get(id=self.request.GET['source_type'])
source_object = source_type.model_class().objects.get(id=self.request.GET['source_pk']) if source_type.model_class().get_qualification_form_class():
context['source_form'] = source_object.get_qualification_form() source_object = source_type.model_class().objects.get(id=self.request.GET['source_pk'])
context['source_form_url'] = source_type.model_class().get_qualification_form_submit_url() context['source_form'] = source_object.get_qualification_form()
try: context['source_form_url'] = source_type.model_class().get_qualification_form_submit_url()
context['association'] = Association.objects.get( try:
source_type=ContentType.objects.get(id=self.request.GET['source_type']), context['association'] = Association.objects.get(
source_pk=self.request.GET['source_pk']) source_type=ContentType.objects.get(id=self.request.GET['source_type']),
except Association.DoesNotExist: source_pk=self.request.GET['source_pk'])
pass except Association.DoesNotExist:
pass
return context return context
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
@ -95,10 +97,11 @@ qualification = csrf_exempt(Qualification.as_view())
class Home(TemplateView): class Home(TemplateView):
template_name = 'welco/home.html' template_name = 'welco/home.html'
source_klass = MailHome
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(Home, self).get_context_data(**kwargs) context = super(Home, self).get_context_data(**kwargs)
context['source'] = MailHome(self.request) context['source'] = self.source_klass(self.request)
context['kb'] = KbHomeZone(self.request) context['kb'] = KbHomeZone(self.request)
context['contacts'] = ContactsHomeZone(self.request) context['contacts'] = ContactsHomeZone(self.request)
return context return context
@ -106,6 +109,12 @@ class Home(TemplateView):
home = Home.as_view() home = Home.as_view()
class HomePhone(Home):
source_klass = PhoneHome
home_phone = HomePhone.as_view()
@csrf_exempt @csrf_exempt
def qualification_done(request): def qualification_done(request):
association = Association.objects.get( association = Association.objects.get(