From cb3fdff202f601c26be58637e2bcfcaba0b9e007 Mon Sep 17 00:00:00 2001 From: Grizzly Date: Tue, 13 Aug 2019 13:05:12 +0000 Subject: [PATCH] =?UTF-8?q?r=C3=A9partition=20des=20preferences=20et=20squ?= =?UTF-8?q?ash=20des=20migrations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tickets/forms.py | 5 +- ...0008_remove_preferences_publish_tickets.py | 48 +++++++++++++++++++ tickets/models.py | 5 +- tickets/preferences/forms.py | 11 +++++ tickets/preferences/models.py | 12 +++++ tickets/views.py | 8 ++++ 6 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 tickets/migrations/0001_squashed_0008_remove_preferences_publish_tickets.py create mode 100644 tickets/preferences/forms.py create mode 100644 tickets/preferences/models.py diff --git a/tickets/forms.py b/tickets/forms.py index 4bb59458..5e565cc7 100644 --- a/tickets/forms.py +++ b/tickets/forms.py @@ -6,7 +6,6 @@ from django.utils.translation import ugettext_lazy as _ from .models import( Ticket, - Preferences, ) class EditTicketForm(FormRevMixin, ModelForm): @@ -22,12 +21,12 @@ class NewTicketForm(ModelForm): class Meta: model = Ticket fields = ['title', 'description', 'email'] - +""" class EditPreferencesForm(ModelForm): - """ Edition des préférences des tickets """ class Meta: model = Preferences fields = '__all__' +""" class ChangeStatusTicketForm(ModelForm): """ Passe un Ticket en résolu """ diff --git a/tickets/migrations/0001_squashed_0008_remove_preferences_publish_tickets.py b/tickets/migrations/0001_squashed_0008_remove_preferences_publish_tickets.py new file mode 100644 index 00000000..2b42726e --- /dev/null +++ b/tickets/migrations/0001_squashed_0008_remove_preferences_publish_tickets.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2019-08-13 12:55 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +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'), ('tickets', '0008_remove_preferences_publish_tickets')] + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + 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)), + ('date', models.DateTimeField(auto_now_add=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_plural': 'Tickets', + 'verbose_name': 'Ticket', + }, + ), + 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)), + ], + options={ + 'verbose_name': 'Préférences des tickets', + }, + ), + ] diff --git a/tickets/models.py b/tickets/models.py index 9cdb334b..ed446064 100644 --- a/tickets/models.py +++ b/tickets/models.py @@ -81,9 +81,8 @@ class Ticket(AclMixin, models.Model): def can_create(user_request,*_args, **_kwargs): """Autorise tout les utilisateurs à créer des tickets""" return True,None - +""" class Preferences(models.Model): - """ Class cannonique définissants les préférences des tickets """ publish_address = models.EmailField( help_text = _("Adresse mail pour annoncer les nouveau tickets (laisser vide pour ne rien annoncer)"), @@ -91,7 +90,7 @@ class Preferences(models.Model): null = True) class Meta: verbose_name = _("Préférences des tickets") - +""" @receiver(post_save, sender=Ticket) def ticket_post_save(**kwargs): diff --git a/tickets/preferences/forms.py b/tickets/preferences/forms.py new file mode 100644 index 00000000..9aa7319e --- /dev/null +++ b/tickets/preferences/forms.py @@ -0,0 +1,11 @@ +from django import forms +from django.forms import ModelForm, Form +from django.utils.translation import ugettext_lazy as _ + +from .models import Preferences + +class EditPreferencesForm(ModelForm): + """ Edition des préférences des tickets """ + class Meta: + model = Preferences + fields = '__all__' diff --git a/tickets/preferences/models.py b/tickets/preferences/models.py new file mode 100644 index 00000000..62a98a09 --- /dev/null +++ b/tickets/preferences/models.py @@ -0,0 +1,12 @@ +from django.db import models +from django.utils.translation import ugettext_lazy as _ + +class Preferences(models.Model): + """ Class cannonique définissants les préférences des tickets """ + + publish_address = models.EmailField( + help_text = _("Adresse mail pour annoncer les nouveau tickets (laisser vide pour ne rien annoncer)"), + max_length = 1000, + null = True) + class Meta: + verbose_name = _("Préférences des tickets") diff --git a/tickets/views.py b/tickets/views.py index 26dce0cd..b09ef3e4 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -19,18 +19,26 @@ from re2o.acl import( ) from preferences.models import GeneralOption + from .models import( Ticket, +) + +from .preferences.models import( Preferences, ) from .forms import ( NewTicketForm, ChangeStatusTicketForm, +) + +from .preferences.forms import ( EditPreferencesForm, ) + def new_ticket(request): """ Vue de création d'un ticket """ ticketform = NewTicketForm(request.POST or None)