472 lines
14 KiB
Python
472 lines
14 KiB
Python
from django import forms
|
|
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
from users.models import AgencyGroup, Agency, Profile, AgencyJob, AgencyNetwork, UserTime, UserNotifications
|
|
from PIL import Image
|
|
from bootstrap_datepicker_plus import DatePickerInput
|
|
from django.utils.translation import gettext as _
|
|
from timemanagement.models import AbsenceReason
|
|
|
|
class AgencyOrganigrammForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Agency
|
|
fields = ['dynamicprofile']
|
|
|
|
labels = {
|
|
'dynamicprofile' : "Dynamischer Steckbrief"
|
|
}
|
|
|
|
class AgencyNetworkForm(forms.ModelForm):
|
|
class Meta:
|
|
model = AgencyNetwork
|
|
fields = ['name', 'publicjoin']
|
|
|
|
labels = {
|
|
"name" : "Name des Agenturverbunds",
|
|
"publicjoin" : "Beitritt ohne Bestätigung"
|
|
}
|
|
|
|
# Change logged Users Data (Usernamen an Email) NUR HIER MÖGLICH!
|
|
class UsersSelfChangeForm(forms.ModelForm):
|
|
email = forms.EmailField()
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = ['email']
|
|
|
|
class AgencyBillMail(forms.ModelForm):
|
|
class Meta:
|
|
model = Agency
|
|
fields = ['payment_address']
|
|
|
|
labels = {
|
|
'payment_address' : 'E-Mail für Rechnungen'
|
|
}
|
|
|
|
class AgencyBillPlan(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = Agency
|
|
fields = ['name','inhaber','agency_email', 'phone', 'street', 'plz', 'city', 'paymentplan', 'agb', 'contract', 'lexofficeid']
|
|
labels = {
|
|
"name" : "Agenturname",
|
|
"inhaber" : "Inhaber",
|
|
"street" : "Straße und Hausnummer",
|
|
"plz" : "PLZ",
|
|
"city" : "Stadt",
|
|
"agency_email" : "E-Mail",
|
|
"phone" : "Telefon",
|
|
"agb" : "AGB akzeptieren",
|
|
"contract" : "AV-Vertrag akzeptieren"
|
|
}
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(AgencyBillPlan, self).__init__(*args, **kwargs)
|
|
self.fields['paymentplan'] = forms.CharField(initial=1, required=True, widget=forms.HiddenInput())
|
|
self.fields['lexofficeid'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput())
|
|
|
|
self.fields['name'] = forms.CharField(required=True, label="Agenturname")
|
|
|
|
self.fields['inhaber'] = forms.CharField(required=True, label="Inhaber")
|
|
|
|
self.fields['agency_email'] = forms.CharField(required=True, label="E-Mailadresse")
|
|
self.fields['phone'] = forms.CharField(required=True, label="Telefon")
|
|
self.fields['street'] = forms.CharField(required=True, label="Straße und Hausnummer")
|
|
self.fields['plz'] = forms.CharField(required=True, label="PLZ")
|
|
self.fields['city'] = forms.CharField(required=True, label="Stadt")
|
|
|
|
self.fields['vve'] = forms.CharField(required=True, label="VVE-Mitgliedsnummer - Ihre Mitgliedsnummer entnehmen Sie bitte der Teilnahmebestätigung zur VVE-Jahrestagung.")
|
|
|
|
self.fields['agb'] = forms.BooleanField(required=True, label="AGB's akzeptieren")
|
|
self.fields['contract'] = forms.BooleanField(required=True, label="AV-Vertrag akzeptieren")
|
|
self.fields['recoverdir'] = forms.BooleanField(required=False, label="Notfallhilfe für 15,00 € bestellen. Sie erhalten eine separate E-Mail vom VVE.")
|
|
|
|
|
|
class AgencyEndBillPlan(forms.ModelForm):
|
|
class Meta:
|
|
model = Agency
|
|
fields = ['paymentplan']
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(AgencyEndBillPlan, self).__init__(*args, **kwargs)
|
|
self.fields['paymentplan'] = forms.CharField(initial=None, required=True, widget=forms.HiddenInput())
|
|
|
|
|
|
# Form für die Benachrichtigungseinstellungen
|
|
'''
|
|
class UsersNotificationForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = Profile
|
|
labels = {
|
|
"news_mail" : "Agentur-News",
|
|
#"user_standard_public_mail" : "Veröffentlichung meiner Standards",
|
|
"agency_new_standard_mail" : "Neue Agentur-Standards",
|
|
'add_new_group_mail' : "Gruppenmitgliedschaften",
|
|
'add_task_mail' : "Tätigkeitsbereich",
|
|
'user_messages_mail' : "Mitteilungen"
|
|
}
|
|
#fields = ['news_mail', 'news_push', 'user_standard_public_mail', 'user_standard_public_push', 'agency_new_standard_mail', 'agency_new_standard_push', 'add_new_group_mail', 'add_new_group_push', 'add_task_mail', 'add_task_push', 'user_messages_mail', 'user_messages_push']
|
|
fields = ['news_mail', 'news_push', 'agency_new_standard_mail', 'agency_new_standard_push', 'add_new_group_mail', 'add_new_group_push', 'add_task_mail', 'add_task_push', 'user_messages_mail', 'user_messages_push']
|
|
'''
|
|
# Form für die Benachrichtigungseinstellungen STANDARDS
|
|
class UsersNotificationFormStandard(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"standard_created_mail" : "Neuer Standard",
|
|
"standard_update_mail" : "Standard verändert",
|
|
"standard_delete_mail" : "Standard gelöscht",
|
|
"standard_created_unpub_mail" : "Neuer, unveröffentlichter Standard"
|
|
|
|
}
|
|
fields = [
|
|
'standard_created_mail',
|
|
'standard_created_push',
|
|
'standard_update_mail',
|
|
'standard_update_push',
|
|
'standard_delete_mail',
|
|
'standard_delete_push',
|
|
'standard_created_unpub_mail',
|
|
'standard_created_unpub_push',
|
|
]
|
|
|
|
|
|
# Form für die Benachrichtigungseinstellungen NEWS
|
|
class UsersNotificationFormNews(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"news_created_mail" : "Neuer Agenturnews",
|
|
|
|
}
|
|
fields = [
|
|
'news_created_mail',
|
|
'news_created_push',
|
|
]
|
|
|
|
# Form für die Benachrichtigungseinstellungen MESSAGES
|
|
class UsersNotificationFormMessages(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"message_received_mail" : "Neuer Mitteilung",
|
|
|
|
}
|
|
fields = [
|
|
'message_received_mail',
|
|
'message_received_push',
|
|
]
|
|
|
|
# Form für die Benachrichtigungseinstellungen CHAT
|
|
class UsersNotificationFormChat(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"chat_received_mail" : "Verpasste Chatnachrichten",
|
|
"chat_room_activity_mail" : "Raumaktivitäten",
|
|
|
|
}
|
|
fields = [
|
|
'chat_received_mail',
|
|
'chat_received_push',
|
|
'chat_room_activity_mail',
|
|
'chat_room_activity_push',
|
|
]
|
|
|
|
# Form für die Benachrichtigungseinstellungen FILES
|
|
class UsersNotificationFormFiles(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"filedir_created_mail" : "Datei/Ordner erstellt",
|
|
"filedir_update_mail" : "Datei/Ordner aktualisiert",
|
|
"filedir_delete_mail" : "Datei/Ordner gelöscht",
|
|
|
|
}
|
|
fields = [
|
|
'filedir_created_mail',
|
|
'filedir_created_push',
|
|
'filedir_update_mail',
|
|
'filedir_update_push',
|
|
'filedir_delete_mail',
|
|
'filedir_delete_push',
|
|
]
|
|
|
|
# Form für die Benachrichtigungseinstellungen ABSENCE AND TIME
|
|
class UsersNotificationFormAbTime(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"absence_created_mail" : "Anfrage erstellt",
|
|
"absence_user_is_rep_mail" : "Als Vertreter eingesetzt",
|
|
"absence_user_is_rep_reminder_mail" : "Erinnerung für Vertretung",
|
|
"time_data_changed_mail" : "Abwesenheit bearbeitet",
|
|
}
|
|
fields = [
|
|
'absence_created_mail',
|
|
'absence_created_push',
|
|
'absence_user_is_rep_mail',
|
|
'absence_user_is_rep_push',
|
|
'absence_user_is_rep_reminder_mail',
|
|
'absence_user_is_rep_reminder_push',
|
|
'time_data_changed_mail',
|
|
'time_data_changed_push',
|
|
]
|
|
|
|
# Form für die Benachrichtigungseinstellungen GRUPPEN
|
|
class UsersNotificationFormGroups(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"group_activity_mail" : "Mitgliedschaftsänderung",
|
|
"group_rights_mail" : "Rechteänderung",
|
|
|
|
}
|
|
fields = [
|
|
'group_activity_mail',
|
|
'group_activity_push',
|
|
'group_rights_mail',
|
|
'group_rights_push',
|
|
]
|
|
|
|
# Form für die Benachrichtigungseinstellungen Tätigkeitsbereiche
|
|
class UsersNotificationFormTasks(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"task_activity_mail" : "Tätigkeiten",
|
|
|
|
}
|
|
fields = [
|
|
'task_activity_mail',
|
|
'task_activity_push',
|
|
]
|
|
|
|
# Form für die Benachrichtigungseinstellungen GRUPPEN
|
|
class UsersNotificationFormAgn(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"agn_standard_created_mail" : "Neuer Standard",
|
|
"agn_standard_copied_mail" : "Standard wurde übernommen",
|
|
"agn_standard_comment_mail" : "Kommentar zu Standard aus meiner Agentur",
|
|
"agn_standard_comment_react_mail" : "Reaktion zu meinem Kommentar",
|
|
"agn_own_change_mail" : "Änderungen meiner Agenturverbunde",
|
|
"agn_other_change_mail" : "Änderung anderer Agenturverbunde",
|
|
}
|
|
fields = [
|
|
'agn_standard_created_mail',
|
|
'agn_standard_created_push',
|
|
'agn_standard_copied_mail',
|
|
'agn_standard_copied_push',
|
|
'agn_standard_comment_mail',
|
|
'agn_standard_comment_push',
|
|
'agn_standard_comment_react_mail',
|
|
'agn_standard_comment_react_push',
|
|
'agn_own_change_mail',
|
|
'agn_own_change_push',
|
|
'agn_other_change_mail',
|
|
'agn_other_change_push',
|
|
]
|
|
|
|
|
|
class UsersNotificationFormOrganizer(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = UserNotifications
|
|
labels = {
|
|
"ql_created_mail" : "Quicklink erstellt",
|
|
"ql_update_mail" : "Quicklink aktualisiert",
|
|
"ql_delete_mail" : "Quicklink gelöscht",
|
|
"contact_created_mail" : "Kontakt erstellt",
|
|
"contact_update_mail" : "Kontakt aktualisiert",
|
|
"contact_delete_mail" : "Kontakt gelöscht",
|
|
"password_created_mail" : "Passwort erstellt",
|
|
"password_update_mail" : "Passwort aktualisiert",
|
|
"password_delete_mail" : "Passwort gelöscht",
|
|
}
|
|
fields = [
|
|
'ql_created_mail',
|
|
'ql_created_push',
|
|
'ql_update_mail',
|
|
'ql_update_push',
|
|
'ql_delete_mail',
|
|
'ql_delete_push',
|
|
'contact_created_mail',
|
|
'contact_created_push',
|
|
'contact_update_mail',
|
|
'contact_update_push',
|
|
'contact_delete_mail',
|
|
'contact_delete_push',
|
|
'password_created_mail',
|
|
'password_created_push',
|
|
'password_update_mail',
|
|
'password_update_push',
|
|
'password_delete_mail',
|
|
'password_delete_push',
|
|
]
|
|
|
|
|
|
|
|
# Usertime Form
|
|
class UserTimeForm(forms.ModelForm):
|
|
class Meta:
|
|
model = UserTime
|
|
labels = {
|
|
"loose_holidedate" : "Resturlaub verfällt am (XX.XX.)",
|
|
"startdate" : "Einstellungsdatum",
|
|
"wd_mo" : "Montag",
|
|
"wd_tu" : "Dienstag",
|
|
"wd_we" : "Mittwoch",
|
|
"wd_th" : "Donnerstag",
|
|
"wd_fr" : "Freitag",
|
|
"wd_sa" : "Samstag",
|
|
"wd_so" : "Sonntag",
|
|
"usetime" : "Zeiterfassung" ,
|
|
"startcount" : "Bisheriges Gleitzeitkonto",
|
|
"usetime_start" : "Zeiterfassung ab"
|
|
}
|
|
fields = ["startcount", "startdate", "usetime", "usetime_start", "wd_mo", "wd_tu", "wd_we", "wd_th", "wd_fr", "wd_sa", "wd_so", "loose_holidedate"]
|
|
widgets = {
|
|
"startdate" : DatePickerInput(options={"format":'DD.MM.YYYY', "locale":'de'}),
|
|
"usetime_start" : DatePickerInput(options={"format":'DD.MM.YYYY', "locale":'de'})
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields['startdate'].required = True
|
|
self.fields['usetime_start'].required = False
|
|
self.fields['startcount'].required = False
|
|
self.fields['usetime'].required = False
|
|
#self.fields['usetime'].widget.attrs['readonly'] = True
|
|
#self.fields['usetime_start'].widget.attrs['readonly'] = True
|
|
|
|
|
|
# PERMISSION GROUPS FORM
|
|
class AgencyGroupPerms(forms.Form):
|
|
'''
|
|
Permission-System
|
|
|
|
Persmissions werden im Model gesetzt, hier automatisch als Form ausgegeben.
|
|
Hat der Nutzer eine der genannten Rechte, wird die Checkbox automatisch TRUE gesetzt.
|
|
Die erstellen Felder werden entsprechend den Feldern hinzugefügt und ausgegeben.
|
|
|
|
@param: user
|
|
- User ist der aufgerufene User!
|
|
'''
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
temprof = AgencyGroup
|
|
for ele in temprof._meta.permissions:
|
|
self.fields[ele[0]] = forms.BooleanField(required=False, initial=False, help_text=(ele[1]))
|
|
|
|
# LOADING ALL MODUL-OPTIONS
|
|
class AgencyModulsForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = Agency
|
|
labels = {
|
|
'module_news' : "Agentur-News",
|
|
'module_organizer' : "Organizer",
|
|
'module_files' : "Dateien",
|
|
'module_organigramm' : "Organigramm",
|
|
'module_messages' : "Mitteilungen",
|
|
'module_chat' : "Chat",
|
|
'module_timemanagement' : "Abwesenheits- und Zeiterfassung",
|
|
#'module_timemanagement' : "Abwesenheitsplanung",
|
|
}
|
|
fields = ['module_news','module_organizer','module_files','module_organigramm', 'module_messages', 'module_chat', 'module_timemanagement']
|
|
|
|
# RAUSNHEMEN WENN DEV DONE
|
|
def __init__(self, *args, **kwargs):
|
|
super(AgencyModulsForm, self).__init__(*args, **kwargs)
|
|
#self.fields['module_timemanagement'].widget.attrs['readonly'] = True
|
|
#self.fields['module_timemanagement'].widget.attrs['disabled'] = True
|
|
|
|
|
|
# NEW USER FORM
|
|
class UserNewUserForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = ["first_name", "last_name", "email"]
|
|
|
|
|
|
error_messages = {
|
|
'email': {
|
|
'unique': _("Diese E-Mailadresse ist bereits vergeben."),
|
|
},
|
|
}
|
|
|
|
# NEW USER PROFILE FORM
|
|
class UserProfileForm(forms.ModelForm):
|
|
|
|
x = forms.FloatField(widget=forms.HiddenInput())
|
|
y = forms.FloatField(widget=forms.HiddenInput())
|
|
width = forms.FloatField(widget=forms.HiddenInput())
|
|
height = forms.FloatField(widget=forms.HiddenInput())
|
|
rotation = forms.FloatField(widget=forms.HiddenInput())
|
|
|
|
class Meta:
|
|
model = Profile
|
|
labels = {
|
|
"persnumber" : "Personalnummer",
|
|
"visible" : "Im Organigramm sichtbar",
|
|
"phonemobile" : "Mobilnummer",
|
|
"phone_public" : "Nur Interne Verwendung der Mobilnummer",
|
|
"phoneland" : "Festnetznummer",
|
|
"image": "Profilbild",
|
|
"func" : "Agenturfunktion",
|
|
"compfunc" : "Tätigkeit"
|
|
}
|
|
widgets = {"parent" : forms.HiddenInput()}
|
|
fields = ["parent", "func", "compfunc", "visible", "phoneland", "phonemobile", "phone_public", "persnumber", "image" ]
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields['func'].queryset = AgencyJob.objects.filter(agency__pk=self.instance.agency.pk)
|
|
|
|
def save(self):
|
|
photo = super(UserProfileForm, self).save()
|
|
try:
|
|
x = self.cleaned_data.get('x')
|
|
y = self.cleaned_data.get('y')
|
|
w = self.cleaned_data.get('width')
|
|
h = self.cleaned_data.get('height')
|
|
rotation = self.cleaned_data.get('rotation')
|
|
image = Image.open(photo.image)
|
|
rotatet_image = image.rotate(rotation, expand=True)
|
|
cropped_image = rotatet_image.crop((x, y, w+x, h+y))
|
|
resized_image = cropped_image.resize((416, 416), Image.ANTIALIAS)
|
|
resized_image.save(photo.image.path)
|
|
return photo
|
|
except:
|
|
print("no photo")
|
|
|
|
|
|
class AbsenceReasonForm(forms.ModelForm):
|
|
|
|
rgb_color = forms.CharField(widget=forms.HiddenInput())
|
|
|
|
class Meta:
|
|
model = AbsenceReason
|
|
labels = {
|
|
"name" : "Bezeichnung",
|
|
"need_confirm" : "Muss bestätigt werden",
|
|
"need_rep" : "Muss vertreten werden",
|
|
"is_holiday" : "Geht vom Urlaub ab",
|
|
"is_time" : "Geht vom Gleitzeitkonto ab"
|
|
}
|
|
fields = ["name", "need_confirm", "need_rep", "is_holiday", "is_time", "rgb_color"]
|