Anfang code der Funktion end of proj approved in sendmails.py
This commit is contained in:
parent
4c016a4a5a
commit
fba8178d48
7 changed files with 124 additions and 7 deletions
|
@ -34,6 +34,7 @@ class ProjectAdmin(admin.ModelAdmin):
|
||||||
# action = ['export_as_csv']
|
# action = ['export_as_csv']
|
||||||
date_hierarchy = 'start'
|
date_hierarchy = 'start'
|
||||||
|
|
||||||
|
|
||||||
@admin.register(BusinessCard)
|
@admin.register(BusinessCard)
|
||||||
class BusinessCardAdmin(admin.ModelAdmin):
|
class BusinessCardAdmin(admin.ModelAdmin):
|
||||||
save_as = True
|
save_as = True
|
||||||
|
@ -45,6 +46,11 @@ class BusinessCardAdmin(admin.ModelAdmin):
|
||||||
class Media:
|
class Media:
|
||||||
js = ('dropdown/js/base.js',)
|
js = ('dropdown/js/base.js',)
|
||||||
|
|
||||||
|
@admin.register(Literature)
|
||||||
|
class LiteratureAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
js = ('dropdown/js/base.js',)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,5 +62,4 @@ admin.site.register([
|
||||||
Travel,
|
Travel,
|
||||||
Email,
|
Email,
|
||||||
List,
|
List,
|
||||||
Literature,
|
|
||||||
])
|
])
|
||||||
|
|
|
@ -83,21 +83,37 @@ class CheckForm(FdbForm):
|
||||||
NUTZUNGSBEDINGUNGEN))
|
NUTZUNGSBEDINGUNGEN))
|
||||||
|
|
||||||
class LiteratureForm(CheckForm):
|
class LiteratureForm(CheckForm):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['selfbuy_give_data'].required = True
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Literature
|
model = Literature
|
||||||
fields = ['cost', 'info', 'source', 'notes']
|
fields = ['cost', 'info', 'source', 'notes', 'selfbuy', 'selfbuy_give_data']
|
||||||
|
class Media:
|
||||||
|
js = ('dropdown/js/base.js',)
|
||||||
|
|
||||||
class EmailForm(CheckForm):
|
class EmailForm(CheckForm):
|
||||||
# TODO: add some javascript to show/hide other-field
|
# TODO: add some javascript to show/hide other-field
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Email
|
model = Email
|
||||||
fields = ['domain', 'address', 'other']
|
fields = ['domain', 'address', 'other']
|
||||||
|
class Media:
|
||||||
|
js = ('dropdown/js/base.js',)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BusinessCardForm(CheckForm):
|
class BusinessCardForm(CheckForm):
|
||||||
|
# this is the code, to change required to false if needed
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['url_of_pic'].required = True
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BusinessCard
|
model = BusinessCard
|
||||||
|
|
||||||
fields = ['project', 'data', 'variant', 'url_of_pic', 'sent_to']
|
fields = ['project', 'data', 'variant', 'url_of_pic', 'sent_to']
|
||||||
|
class Media:
|
||||||
|
js = ('dropdown/js/base.js',)
|
||||||
|
|
||||||
class ListForm(CheckForm):
|
class ListForm(CheckForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -50,6 +50,8 @@ class Command(BaseCommand):
|
||||||
def end_of_projects_reached(self):
|
def end_of_projects_reached(self):
|
||||||
''' end of project reached '''
|
''' end of project reached '''
|
||||||
# get all projects which ended
|
# get all projects which ended
|
||||||
|
|
||||||
|
print(Project.objects.filter(end__lt = date.today()))
|
||||||
old = Project.objects.filter(end__lt = date.today())\
|
old = Project.objects.filter(end__lt = date.today())\
|
||||||
.exclude(end_mail_send = True)
|
.exclude(end_mail_send = True)
|
||||||
|
|
||||||
|
@ -70,6 +72,31 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS('end_of_projects_reached() executed.'))
|
self.stdout.write(self.style.SUCCESS('end_of_projects_reached() executed.'))
|
||||||
|
|
||||||
|
def end_of_projects_approved(self):
|
||||||
|
''' end of project approved '''
|
||||||
|
# get all projects where end was reached already, and send mails for the ones already set to status "ended" by the admins
|
||||||
|
|
||||||
|
approved_end = Project.objects.filter(status = 'END')\
|
||||||
|
.exclude(end_mail_send = False)
|
||||||
|
print(approved_end)
|
||||||
|
mail_template = get_template('input/if_end_of_project.txt')
|
||||||
|
for project in approved_end:
|
||||||
|
context = {'project': project}
|
||||||
|
context['URLPREFIX'] = settings.URLPREFIX
|
||||||
|
try:
|
||||||
|
send_mail('Projektende erreicht',
|
||||||
|
mail_template.render(context),
|
||||||
|
IF_EMAIL,
|
||||||
|
[IF_EMAIL],
|
||||||
|
fail_silently=False)
|
||||||
|
project.end_mail_send = True
|
||||||
|
project.save()
|
||||||
|
except BadHeaderError:
|
||||||
|
self.stdout.write(self.style.ERROR('Invalid header found.'))
|
||||||
|
|
||||||
|
self.stdout.write(self.style.SUCCESS('end_of_projects_reached() executed.'))
|
||||||
|
|
||||||
|
|
||||||
def surveymails_to_object(self, supported, name='', type='LIB'):
|
def surveymails_to_object(self, supported, name='', type='LIB'):
|
||||||
mytype=type
|
mytype=type
|
||||||
myname = name
|
myname = name
|
||||||
|
@ -158,6 +185,7 @@ class Command(BaseCommand):
|
||||||
'''the main function which is called by the custom command'''
|
'''the main function which is called by the custom command'''
|
||||||
|
|
||||||
self.end_of_projects_reached()
|
self.end_of_projects_reached()
|
||||||
|
self.end_of_projects_approved()
|
||||||
self.surveymails_to_lib()
|
self.surveymails_to_lib()
|
||||||
self.surveymails_to_hon()
|
self.surveymails_to_hon()
|
||||||
self.surveymails_to_ifg()
|
self.surveymails_to_ifg()
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Generated by Django 4.1.2 on 2022-11-11 10:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('input', '0063_businesscard_url_of_pic_alter_ifg_notes_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='businesscard',
|
||||||
|
name='send_data_to_print',
|
||||||
|
field=models.BooleanField(default=False, help_text='Hiermit erlaube ich die Weitergabe meiner Daten (Name, Postadresse) an den von Wikimedia Deutschland ausgewählten Dienstleister (z. B. <a href="wir-machen-druck.de">wir-machen-druck.de</a>) zum Zwecke des direkten Versands der Druckerzeugnisse an mich.', verbose_name='Datenweitergabe erlauben'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='literature',
|
||||||
|
name='selfbuy',
|
||||||
|
field=models.CharField(choices=[('TRUE', 'Ich möchte das Werk selbst kaufen und per Kostenerstattung bei Wikimedia Deutschland abrechnen.'), ('FALSE', 'Ich möchte, dass Wikimedia Deutschland das Werk für mich kauft')], default='TRUE', max_length=10, verbose_name='Selbstkauf?'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='literature',
|
||||||
|
name='selfbuy_give_data',
|
||||||
|
field=models.BooleanField(default=False, help_text='Weitergabe meiner Daten (Name, Postadresse) an den von mir angegebenen Anbieter/Dienstleister.', verbose_name='Datenweitergabe erlauben'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='businesscard',
|
||||||
|
name='url_of_pic',
|
||||||
|
field=models.CharField(default='', help_text='Bitte gib die Wikimedia-Commons-URL des Bildes an.', max_length=200, verbose_name='Url des Bildes'),
|
||||||
|
),
|
||||||
|
]
|
23
input/migrations/0065_alter_literature_selfbuy_and_more.py
Normal file
23
input/migrations/0065_alter_literature_selfbuy_and_more.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 4.1.2 on 2022-11-11 11:20
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('input', '0064_businesscard_send_data_to_print_literature_selfbuy_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='literature',
|
||||||
|
name='selfbuy',
|
||||||
|
field=models.CharField(choices=[('TRUE', 'Ich möchte das Werk selbst kaufen und per Kostenerstattung bei Wikimedia Deutschland abrechnen.'), ('FALSE', 'Ich möchte, dass Wikimedia Deutschland das Werk für mich kauft'), ('NONE', 'Nichts ausgewählt')], default='TRUE', max_length=10, verbose_name='Selbstkauf?'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='literature',
|
||||||
|
name='selfbuy_give_data',
|
||||||
|
field=models.BooleanField(default='NONE', help_text='Weitergabe meiner Daten (Name, Postadresse) an den von mir angegebenen Anbieter/Dienstleister.', verbose_name='Datenweitergabe erlauben'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -190,17 +190,27 @@ class Library(Grant):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.library
|
return self.library
|
||||||
|
|
||||||
|
|
||||||
|
SELFBUY_CHOICES = {'TRUE': format_html('Ich möchte das Werk selbst kaufen und per Kostenerstattung bei Wikimedia Deutschland abrechnen.'),
|
||||||
|
'FALSE': format_html('Ich möchte, dass Wikimedia Deutschland das Werk für mich kauft'),
|
||||||
|
'NONE': format_html('Nichts ausgewählt')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Literature(Grant):
|
class Literature(Grant):
|
||||||
info = models.CharField(max_length=500, verbose_name='Informationen zum Werk',
|
info = models.CharField(max_length=500, verbose_name='Informationen zum Werk',
|
||||||
help_text=format_html("Bitte gib alle Informationen zum benötigten Werk an,<br>\
|
help_text=format_html("Bitte gib alle Informationen zum benötigten Werk an,<br>\
|
||||||
die eine eindeutige Identifizierung ermöglichen (Autor, Titel, Verlag, ISBN, ...)"))
|
die eine eindeutige Identifizierung ermöglichen (Autor, Titel, Verlag, ISBN, ...)"))
|
||||||
source = models.CharField(max_length=200, verbose_name='Bezugsquelle',
|
source = models.CharField(max_length=200, verbose_name='Bezugsquelle',
|
||||||
help_text="Bitte gib an, wo du das Werk kaufen möchtest.")
|
help_text="Bitte gib an, wo du das Werk kaufen möchtest.")
|
||||||
|
selfbuy = models.CharField( max_length=10, verbose_name='Selbstkauf?', choices=SELFBUY_CHOICES.items(), default='TRUE')
|
||||||
|
selfbuy_give_data = models.BooleanField(default='NONE', verbose_name=format_html('Datenweitergabe erlauben'), help_text=format_html('Weitergabe meiner Daten (Name, Postadresse) an den von mir angegebenen Anbieter/Dienstleister.'))
|
||||||
|
|
||||||
class IFG(Grant):
|
class IFG(Grant):
|
||||||
url = models.URLField(max_length=2000, verbose_name="URL",
|
url = models.URLField(max_length=2000, verbose_name="URL",
|
||||||
help_text="Bitte gib den Link zu deiner Anfrage bei Frag den Staat an.")
|
help_text="Bitte gib den Link zu deiner Anfrage bei Frag den Staat an.")
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "IFG-Anfrage von " + self.realname
|
return "IFG-Anfrage von " + self.realname
|
||||||
|
|
||||||
|
@ -270,4 +280,4 @@ class BusinessCard(Extern):
|
||||||
|
|
||||||
sent_to = models.TextField(max_length=1000, verbose_name='Versandadresse',
|
sent_to = models.TextField(max_length=1000, verbose_name='Versandadresse',
|
||||||
default='', help_text="Bitte gib den Namen und die vollständige Adresse ein, an welche die Visitenkarten geschickt werden sollen.")
|
default='', help_text="Bitte gib den Namen und die vollständige Adresse ein, an welche die Visitenkarten geschickt werden sollen.")
|
||||||
send_data_to_print = models.BooleanField(null=False, verbose_name=format_html('Datenweitergabe erlauben'), help_text=format_html('Hiermit erlaube ich die Weitergabe meiner Daten (Name, Postadresse) an den von Wikimedia Deutschland ausgewählten Dienstleister (z. B. <a href="wir-machen-druck.de">wir-machen-druck.de</a>) zum Zwecke des direkten Versands der Druckerzeugnisse an mich.'))
|
send_data_to_print = models.BooleanField(default=False, verbose_name=format_html('Datenweitergabe erlauben'), help_text=format_html('Hiermit erlaube ich die Weitergabe meiner Daten (Name, Postadresse) an den von Wikimedia Deutschland ausgewählten Dienstleister (z. B. <a href="wir-machen-druck.de">wir-machen-druck.de</a>) zum Zwecke des direkten Versands der Druckerzeugnisse an mich.'))
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# mail for IF-OTRS
|
# mail for IF-OTRS
|
||||||
IF_EMAIL = 'community@wikimedia.de'
|
#IF_EMAIL = 'community@wikimedia.de'
|
||||||
SURVEY_EMAIL = 'christof.pins@wikimedia.de'
|
IF_EMAIL = 'luca@cannabinieri.de'
|
||||||
|
#SURVEY_EMAIL = 'christof.pins@wikimedia.de'
|
||||||
|
SURVEY_EMAIL = 'luca.wulf@cannabinieri.de'
|
||||||
|
|
||||||
# prefix for urls
|
# prefix for urls
|
||||||
SURVEYPREFIX = 'https://wikimedia.sslsurvey.de/Foerderbarometer/?'
|
SURVEYPREFIX = 'https://wikimedia.sslsurvey.de/Foerderbarometer/?'
|
||||||
|
|
Loading…
Reference in a new issue