From: Guillaume Pellerin Date: Wed, 22 Mar 2017 23:27:48 +0000 (+0100) Subject: Upgrade Project form, makes (almost) every fields required, add organization and... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=3879dcc21ae49b9cc73a75c6bf07661a04817277;p=mezzo.git Upgrade Project form, makes (almost) every fields required, add organization and position fields --- diff --git a/app/local_settings.py b/app/local_settings.py index 592145ad..8ee6dc75 100644 --- a/app/local_settings.py +++ b/app/local_settings.py @@ -73,9 +73,9 @@ FILEBROWSER_SELECT_FORMATS = { EMAIL_HOST = 'smtp.ircam.fr' EMAIL_PORT = '25' -DEFAULT_FROM_EMAIL = 'www@ircam.fr' -DEFAULT_TO_EMAIL = 'drh@ircam.fr' -EMAIL_SUBJECT_PREFIX = "[IRCAM WWW]" +DEFAULT_FROM_EMAIL = 'vertigo@iuk.fraunhofer.de' +DEFAULT_TO_EMAIL = 'vertigo@iuk.fraunhofer.de' +EMAIL_SUBJECT_PREFIX = '[Vertigo]' SITE_TITLE = 'IRCAM' SITE_TAGLINE = 'Institut de Recherche et de Coordination Acoustique et Musique' diff --git a/app/organization/network/migrations/0093_auto_20170322_1846.py b/app/organization/network/migrations/0093_auto_20170322_1846.py new file mode 100644 index 00000000..aa19a751 --- /dev/null +++ b/app/organization/network/migrations/0093_auto_20170322_1846.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.11 on 2017-03-22 17:46 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('organization-network', '0092_auto_20170314_1918'), + ] + + operations = [ + migrations.AddField( + model_name='person', + name='organization_name', + field=models.CharField(blank=True, max_length=128, null=True, verbose_name='organization_name'), + ), + migrations.AddField( + model_name='person', + name='position', + field=models.CharField(blank=True, max_length=128, null=True, verbose_name='position'), + ), + ] diff --git a/app/organization/network/models.py b/app/organization/network/models.py index 94f5a575..aaf27aa9 100644 --- a/app/organization/network/models.py +++ b/app/organization/network/models.py @@ -215,6 +215,8 @@ class Person(Displayable, AdminThumbMixin, Address): bio = RichTextField(_('biography'), blank=True) role = models.CharField(_('role'), max_length=256, blank=True, null=True) external_id = models.CharField(_('external ID'), blank=True, null=True, max_length=128) + organization_name = models.CharField(_('organization name'), blank=True, null=True, max_length=128) + position = models.CharField(_('position'), blank=True, null=True, max_length=128) class Meta: verbose_name = _('person') diff --git a/app/organization/projects/forms.py b/app/organization/projects/forms.py index 5ab93ff0..ee93d0e1 100644 --- a/app/organization/projects/forms.py +++ b/app/organization/projects/forms.py @@ -59,6 +59,7 @@ class ProjectForm(ModelForm): super(ProjectForm, self).__init__(*args, **kwargs) self.fields['title'].label = "Project name" self.fields['keywords'].help_text = "5 comma separated keywords" + self.fields['keywords'].required = True class Meta: model = Project @@ -94,14 +95,40 @@ class ProjectUserImageInline(InlineFormSet): fields = ['file', 'credits'] +class ProjectLinkInline(InlineFormSet): + + extra = 3 + model = ProjectLink + prefix = 'Public link' + text = "To be published only for ICT-Projects selected by the consortium" + can_delete = False + fields = ['url', 'type'] + + + +class ProjectContactForm(ModelForm): + + def __init__(self, *args, **kwargs): + super(ProjectContactForm, self).__init__(*args, **kwargs) + self.fields['organization_name'].help_text = "The organization related to the contact" + self.fields['position'].help_text = "The position of the contact in the organization" + for field in self._meta.fields: + self.fields[field].required = True + + class Meta: + model = ProjectContact + fields = ('first_name', 'last_name', 'email', 'organization_name', + 'position', 'address', 'telephone', 'address', 'postal_code', + 'city', 'country') + + class ProjectContactInline(InlineFormSet): max_num = 1 model = ProjectContact + form_class = ProjectContactForm prefix = 'Private project contact' can_delete = False - fields = ['first_name', 'last_name', 'address', 'email', - 'telephone', 'address', 'postal_code', 'city', 'country'] class OrganizationContactInline(InlineFormSet): diff --git a/app/organization/projects/models.py b/app/organization/projects/models.py index 75116285..7257e0ea 100644 --- a/app/organization/projects/models.py +++ b/app/organization/projects/models.py @@ -342,7 +342,7 @@ class ProjectPublicData(models.Model): resources_description = models.TextField(_('resource description'), help_text="Resources available to the artist -- e.g. office facility, studio facility, technical equipment, internet connection, laboratory, and periods of availability for artistic production, staff possibly allocated to the project, available budget for travel, consumables and equipment, etc... (50 – 100 words).") period = models.CharField(_('period of implementation'), max_length=128, help_text="Possible period of implementation (must be part of the project implementation workplan)") image = models.FileField(_("Image"), max_length=1024, upload_to="user/images/%Y/%m/%d/", help_text="Representing the project") - image_credits = models.CharField(_('Image credits'), max_length=256, blank=True, null=True) + image_credits = models.CharField(_('Image credits'), max_length=256) class Meta: verbose_name = 'Project public data' diff --git a/app/organization/projects/views.py b/app/organization/projects/views.py index 7130564f..4f3da05f 100644 --- a/app/organization/projects/views.py +++ b/app/organization/projects/views.py @@ -21,6 +21,9 @@ from django.shortcuts import render from django.views.generic.detail import SingleObjectMixin +from django.template.loader import render_to_string, get_template +from django.core.mail import EmailMessage +from django.template import Context from dal import autocomplete from dal_select2_queryset_sequence.views import Select2QuerySetSequenceView from mezzanine_agenda.models import Event @@ -141,24 +144,45 @@ class ProjectICTSubmissionView(ProjectCallMixin, TemplateView): model = Project template_name='projects/project_ict_submission.html' - - + class ProjectICTCreateView(ProjectCallMixin, CreateWithInlinesView): model = Project form_class = ProjectForm template_name='projects/project_ict_create.html' - inlines = [ProjectPublicDataInline, ProjectPrivateDataInline, ProjectUserImageInline, ProjectContactInline,] + inlines = [ProjectPublicDataInline, ProjectPrivateDataInline, ProjectUserImageInline, + ProjectContactInline] topic = 'ICT' - def forms_valid(self, form, inlines): self.object = form.save() self.call = ProjectCall.objects.get(slug=self.kwargs['slug']) self.object.call = self.call self.object.topic, c = ProjectTopic.objects.get_or_create(name='ICT') self.object.save() + + for formset in inlines: + print(formset.prefix) + if 'contact' in formset.prefix: + for f in formset: + contact_data = f.cleaned_data + contact_email = contact_data.get("email") + + from_email = settings.DEFAULT_FROM_EMAIL + to_email = [contact_email, settings.DEFAULT_TO_EMAIL] + subject = settings.EMAIL_SUBJECT_PREFIX + ' ' + self.call.title + ctx = { + 'first_name': contact_data['first_name'], + 'last_name': contact_data['last_name'], + 'project_title': self.object.title, + } + + message = get_template('projects/project_ict_create_notification.html').render(Context(ctx)) + msg = EmailMessage(subject, message, to=to_email, from_email=from_email) + msg.content_subtype = 'html' + msg.send() + return super(ProjectICTCreateView, self).forms_valid(form, inlines) def get_success_url(self): diff --git a/app/themes/vertigo_starts_eu/templates/projects/inc/project_validation.html b/app/themes/vertigo_starts_eu/templates/projects/inc/project_validation.html new file mode 100644 index 00000000..947af053 --- /dev/null +++ b/app/themes/vertigo_starts_eu/templates/projects/inc/project_validation.html @@ -0,0 +1,7 @@ +

Thank you for applying for the Vertigo Call for Projects and your interest in hosting an artist.

+

With the submission of data and documents about your project, you declare, that you are allowed to establish a cooperation with an artist funded by the Vertigo project.

+

We will keep you informed about the further project selection process.

+ +{# You submitted the following data:#} + +

If you wish to change the information or would like to add further information, please send an email containing the new information to vertigo@iuk.fraunhofer.de.

diff --git a/app/themes/vertigo_starts_eu/templates/projects/project_ict_create.html b/app/themes/vertigo_starts_eu/templates/projects/project_ict_create.html index 8fc4a57b..ad66d183 100644 --- a/app/themes/vertigo_starts_eu/templates/projects/project_ict_create.html +++ b/app/themes/vertigo_starts_eu/templates/projects/project_ict_create.html @@ -21,7 +21,7 @@ {% editable object.title %}

{% trans "Project submission form" %}

{% endeditable %} -

All fields are required

+

All fields are mandatory / required

{% endblock %} {% block page_content %} @@ -38,13 +38,16 @@ {% elif "Public data" in formset.prefix %}
To be published only for ICT-Projects selected by the consortium
{% elif "Private images" in formset.prefix %} -
3 key images for inspiring artist + any video content available
+
3 key images for inspiring artist
{% endif %} {% for form in formset %} {% fields_for form %} {% endfor %} {% endfor %}
+

All fields are mandatory / required

+

With the submission of data and documents about your project, you declare, that you are allowed to establish a cooperation with an artist funded by the Vertigo project.

+
diff --git a/app/themes/vertigo_starts_eu/templates/projects/project_ict_create_notification.html b/app/themes/vertigo_starts_eu/templates/projects/project_ict_create_notification.html new file mode 100644 index 00000000..cb1d6c4b --- /dev/null +++ b/app/themes/vertigo_starts_eu/templates/projects/project_ict_create_notification.html @@ -0,0 +1,11 @@ + + + + + + + +

Dear {{ first_name }} {{ last_name }},

+ {% include 'projects/inc/project_validation.html' %} + + diff --git a/app/themes/vertigo_starts_eu/templates/projects/project_ict_validation.html b/app/themes/vertigo_starts_eu/templates/projects/project_ict_validation.html index 434ee296..7bd86304 100644 --- a/app/themes/vertigo_starts_eu/templates/projects/project_ict_validation.html +++ b/app/themes/vertigo_starts_eu/templates/projects/project_ict_validation.html @@ -25,9 +25,8 @@ {% block page_content %}
-

Thank you for having submitted your project. It will evaluated in the next few days by the evaluation board and you will then receive an email notification for the result.

-

For the first call of 2017, you cannot update your project data on your own, so please send an email to the board if you need any modification.

-

See you soon!

+

Dear Submitter,

+ {% include 'projects/inc/project_validation.html' %}
{% endblock %}