diff --git a/tickets/migrations/0001_squashed_0007_preferences_publish_tickets.py b/tickets/migrations/0001_initial.py similarity index 56% rename from tickets/migrations/0001_squashed_0007_preferences_publish_tickets.py rename to tickets/migrations/0001_initial.py index b2293a4a..a2d1a5d8 100644 --- a/tickets/migrations/0001_squashed_0007_preferences_publish_tickets.py +++ b/tickets/migrations/0001_initial.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.10.7 on 2019-08-16 13:41 +# Generated by Django 1.10.7 on 2019-08-19 08:19 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion +import re2o.mixins class Migration(migrations.Migration): - replaces = [('tickets', '0001_initial'), ('tickets', '0002_auto_20190710_0952'), ('tickets', '0003_ticket_email'), ('tickets', '0004_auto_20190712_1205'), ('tickets', '0005_auto_20190712_1209'), ('tickets', '0006_preferences'), ('tickets', '0007_preferences_publish_tickets')] - initial = True dependencies = [ @@ -18,32 +17,32 @@ class Migration(migrations.Migration): ] operations = [ + migrations.CreateModel( + name='Preferences', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('publish_address', models.EmailField(help_text='Email address to publish the new tickets (leave empty for no publications)', max_length=1000, null=True)), + ('mail_language', models.IntegerField(choices=[(0, 'Français'), (1, 'English')], default=0)), + ], + options={ + 'verbose_name': "Ticket's settings", + }, + ), migrations.CreateModel( name='Ticket', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(help_text='Nom du ticket', max_length=255)), - ('description', models.TextField(help_text='Description du ticket', max_length=3000)), + ('title', models.CharField(help_text='Title of the ticket', max_length=255)), + ('description', models.TextField(help_text='Description of the ticket', max_length=3000)), ('date', models.DateTimeField(auto_now_add=True)), + ('email', models.EmailField(help_text='An email address to get back to you', max_length=100, null=True)), ('solved', models.BooleanField(default=False)), - ('assigned_staff', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='tickets_assigned', to=settings.AUTH_USER_MODEL)), ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tickets', to=settings.AUTH_USER_MODEL)), - ('email', models.EmailField(help_text='Une adresse mail pour vous recontacter', max_length=100, null=True)), ], options={ 'verbose_name': 'Ticket', 'verbose_name_plural': 'Tickets', }, - ), - migrations.CreateModel( - name='Preferences', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('publish_address', models.EmailField(help_text='Adresse mail pour annoncer les nouveau tickets (laisser vide pour ne rien annoncer)', max_length=1000, null=True)), - ('publish_tickets', models.BooleanField(default=True, help_text='Publier ou pas les tickets')), - ], - options={ - 'verbose_name': 'Préférences des tickets', - }, + bases=(re2o.mixins.AclMixin, models.Model), ), ] diff --git a/tickets/preferences/models.py b/tickets/preferences/models.py index 684c192e..da77fdff 100644 --- a/tickets/preferences/models.py +++ b/tickets/preferences/models.py @@ -8,5 +8,12 @@ class Preferences(models.Model): help_text = _("Email address to publish the new tickets (leave empty for no publications)"), max_length = 1000, null = True) + LANG_FR = 0 + LANG_EN = 1 + LANGUES = ( + (0,_("Français")), + (1,_("English")), + ) + mail_language = models.IntegerField(choices=LANGUES,default = LANG_FR) class Meta: verbose_name = _("Ticket's settings") diff --git a/tickets/templates/tickets/form_preferences.html b/tickets/templates/tickets/form_preferences.html index 03a6a333..5c7e5d5e 100644 --- a/tickets/templates/tickets/form_preferences.html +++ b/tickets/templates/tickets/form_preferences.html @@ -42,6 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% csrf_token %} {% bootstrap_field preferencesform.publish_address %} + {% bootstrap_field preferencesform.mail_language %} {% bootstrap_button "Editer" button_type="submit" icon='ok' button_class='btn-success' %}
{% endblock %} diff --git a/tickets/templates/tickets/preferences.html b/tickets/templates/tickets/preferences.html index 8f9fe490..60cbfac6 100644 --- a/tickets/templates/tickets/preferences.html +++ b/tickets/templates/tickets/preferences.html @@ -18,14 +18,17 @@
- - + {% if preferences.publish_address %} {% else %} {% endif %} + + +

Email de publication

{% trans "Publication email address"%}

{{ preferences.publish_address }}

{% trans "Pas d'adresse, les tickets ne sont pas annoncés" %}

{% trans "Email language" %}

{{ language }}

+
diff --git a/tickets/templates/tickets/publication_mail_en b/tickets/templates/tickets/publication_mail_en new file mode 100644 index 00000000..969ed1f9 --- /dev/null +++ b/tickets/templates/tickets/publication_mail_en @@ -0,0 +1,12 @@ +{% if ticket.user %} {{ ticket.user.get_full_name }} opened a ticket. +Profil: {{site_url}}{% url 'users:profil' ticket.user.id%} +Answer to the address: {{ticket.user.get_mail}}. + +{% else %} +An anonymous user (not authenticated) opened a ticket +Answer to the address:{{ticket.email}}. +{% endif %} + +Title: {{ticket.title}} + +Description: {{ticket.description}} diff --git a/tickets/templates/tickets/publication_mail b/tickets/templates/tickets/publication_mail_fr similarity index 100% rename from tickets/templates/tickets/publication_mail rename to tickets/templates/tickets/publication_mail_fr diff --git a/tickets/views.py b/tickets/views.py index 26b5cad5..e450721f 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -179,8 +179,8 @@ def profil(request,user): def preferences(request): """ View to display the settings of the tickets in the preferences page""" - preferences = Preferences.objects.first() - context = {'preferences':preferences} + pref = Preferences.objects.first() + context = {'preferences':pref,'language':str(pref.LANGUES[pref.mail_language][1])} return render_to_string('tickets/preferences.html', context=context, request=request, using=None) def contact(request):