mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 15:12:25 +00:00
migrations et choix de la langue du mail
This commit is contained in:
parent
b0fb188e24
commit
9185b121af
7 changed files with 44 additions and 22 deletions
|
@ -1,16 +1,15 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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 __future__ import unicode_literals
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
import re2o.mixins
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
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
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
@ -18,32 +17,32 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
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(
|
migrations.CreateModel(
|
||||||
name='Ticket',
|
name='Ticket',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('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)),
|
('title', models.CharField(help_text='Title of the ticket', max_length=255)),
|
||||||
('description', models.TextField(help_text='Description du ticket', max_length=3000)),
|
('description', models.TextField(help_text='Description of the ticket', max_length=3000)),
|
||||||
('date', models.DateTimeField(auto_now_add=True)),
|
('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)),
|
('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)),
|
('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={
|
options={
|
||||||
'verbose_name': 'Ticket',
|
'verbose_name': 'Ticket',
|
||||||
'verbose_name_plural': 'Tickets',
|
'verbose_name_plural': 'Tickets',
|
||||||
},
|
},
|
||||||
),
|
bases=(re2o.mixins.AclMixin, models.Model),
|
||||||
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',
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
]
|
]
|
|
@ -8,5 +8,12 @@ class Preferences(models.Model):
|
||||||
help_text = _("Email address to publish the new tickets (leave empty for no publications)"),
|
help_text = _("Email address to publish the new tickets (leave empty for no publications)"),
|
||||||
max_length = 1000,
|
max_length = 1000,
|
||||||
null = True)
|
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:
|
class Meta:
|
||||||
verbose_name = _("Ticket's settings")
|
verbose_name = _("Ticket's settings")
|
||||||
|
|
|
@ -42,6 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_field preferencesform.publish_address %}
|
{% bootstrap_field preferencesform.publish_address %}
|
||||||
|
{% bootstrap_field preferencesform.mail_language %}
|
||||||
{% bootstrap_button "Editer" button_type="submit" icon='ok' button_class='btn-success' %}
|
{% bootstrap_button "Editer" button_type="submit" icon='ok' button_class='btn-success' %}
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -18,14 +18,17 @@
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th><p>Email de publication</p></th>
|
<th><p>{% trans "Publication email address"%}</p></th>
|
||||||
|
|
||||||
{% if preferences.publish_address %}
|
{% if preferences.publish_address %}
|
||||||
<td><p>{{ preferences.publish_address }}</p></td>
|
<td><p>{{ preferences.publish_address }}</p></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><p>{% trans "Pas d'adresse, les tickets ne sont pas annoncés" %}</p></td>
|
<td><p>{% trans "Pas d'adresse, les tickets ne sont pas annoncés" %}</p></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><p>{% trans "Email language" %}</p></th>
|
||||||
|
<td><p>{{ language }}</p></th>
|
||||||
|
</tr>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
12
tickets/templates/tickets/publication_mail_en
Normal file
12
tickets/templates/tickets/publication_mail_en
Normal file
|
@ -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}}
|
|
@ -179,8 +179,8 @@ def profil(request,user):
|
||||||
|
|
||||||
def preferences(request):
|
def preferences(request):
|
||||||
""" View to display the settings of the tickets in the preferences page"""
|
""" View to display the settings of the tickets in the preferences page"""
|
||||||
preferences = Preferences.objects.first()
|
pref = Preferences.objects.first()
|
||||||
context = {'preferences':preferences}
|
context = {'preferences':pref,'language':str(pref.LANGUES[pref.mail_language][1])}
|
||||||
return render_to_string('tickets/preferences.html', context=context, request=request, using=None)
|
return render_to_string('tickets/preferences.html', context=context, request=request, using=None)
|
||||||
|
|
||||||
def contact(request):
|
def contact(request):
|
||||||
|
|
Loading…
Reference in a new issue