Settings AGentur umgebaut, Cropper und drehen eingebaut
This commit is contained in:
parent
adefeb1224
commit
06a1428ce9
Binary file not shown.
|
|
@ -7,8 +7,8 @@ from django.utils import timezone
|
|||
|
||||
|
||||
def user_directory_path(instance, filename):
|
||||
# file will be uploaded to MEDIA_ROOT/agency_<id>/<subdirs>/<filename>
|
||||
return 'agency_{0}/{1}/{2}'.format(instance.agency.pk, instance.subdir, filename)
|
||||
# file will be uploaded to MEDIA_ROOT/agency_<id>/files/<subdirs>/<filename>
|
||||
return 'agency_{0}/files/{1}/{2}'.format(instance.agency.pk, instance.subdir, filename)
|
||||
|
||||
|
||||
class Data(models.Model):
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -14,6 +14,15 @@ User._meta.get_field('email').blank = False
|
|||
User._meta.get_field('first_name').blank = False
|
||||
User._meta.get_field('last_name').blank = False
|
||||
|
||||
def picturepath_agency(instance, filename):
|
||||
# file will be uploaded to MEDIA_ROOT/agency_<id>/<subdirs>/<filename>
|
||||
return 'agency_{0}/agencystats/{1}'.format(instance.pk, filename)
|
||||
|
||||
|
||||
def picturepath_user(instance, filename):
|
||||
# file will be uploaded to MEDIA_ROOT/agency_<id>/<subdirs>/<filename>
|
||||
return 'agency_{0}/agencystats/profilepics/{1}'.format(instance.pk, filename)
|
||||
|
||||
'''
|
||||
Class Agency
|
||||
|
||||
|
|
@ -29,10 +38,10 @@ class Agency(models.Model):
|
|||
inhaber = models.CharField(default="", max_length=200, blank=True)
|
||||
street = models.CharField(default="", max_length=200, blank=True)
|
||||
city = models.CharField(default="", max_length=200, blank=True)
|
||||
email = models.EmailField(default="", blank=True)
|
||||
phone = models.CharField(default="", max_length=50, blank=True)
|
||||
persnumber = models.CharField(default="", max_length=50, blank=True)
|
||||
agencypic = models.ImageField(default='agencymain/default.jpg', upload_to='agencymain', blank=True)
|
||||
plz = models.CharField(default="", max_length=5, blank=True)
|
||||
agency_email = models.EmailField(default="", blank=True)
|
||||
phone = models.CharField(default="", max_length=50, blank=True)
|
||||
agencypic = models.ImageField(default='agencymain/default.jpg', upload_to=picturepath_agency, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.name}'
|
||||
|
|
@ -88,9 +97,31 @@ class Profile(models.Model):
|
|||
func = models.CharField(choices=agency_task, default="", max_length=50)
|
||||
# Wenn dieses Profil gelöscht wird, wird NICHT die Agency geslöscht
|
||||
agency = models.ForeignKey(Agency, on_delete=models.PROTECT)
|
||||
image = models.ImageField(default='userprofilepics/default.jpg', upload_to='userprofilepics', blank=True)
|
||||
image = models.ImageField(default='userprofilepics/default.jpg', upload_to=picturepath_user, blank=True)
|
||||
compfunc = models.CharField(max_length=60, blank=True)
|
||||
visible = models.BooleanField(default=True)
|
||||
persnumber = models.CharField(default="", max_length=50, blank=True)
|
||||
|
||||
# NOTIFICATIONS
|
||||
#NEWS
|
||||
# Mitteilung bei neuen News innerhalb der Agentur
|
||||
news_mail = models.BooleanField(default=True)
|
||||
news_push = models.BooleanField(default=True)
|
||||
|
||||
#STANDARDS
|
||||
# Benutzerstandard wurde veröffentlicht
|
||||
user_standard_public_mail = models.BooleanField(default=False)
|
||||
user_standard_public_push = models.BooleanField(default=True)
|
||||
|
||||
#STANDARDS
|
||||
# Neue Standards
|
||||
agency_new_standard_mail = models.BooleanField(default=False)
|
||||
agency_new_standard_push = models.BooleanField(default=True)
|
||||
|
||||
# GROUPS
|
||||
# Neuer Gruppe zugeordnet
|
||||
add_new_group_mail = models.BooleanField(default=False)
|
||||
add_new_group_push = models.BooleanField(default=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.user.last_name}'
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
{{ request.user.profile.agency.street }}
|
||||
</p>
|
||||
<p>
|
||||
{{ request.user.profile.agency.city }}
|
||||
{{ request.user.profile.agency.plz }} {{ request.user.profile.agency.city }}
|
||||
</p>
|
||||
<h6><b>Kontaktdaten</b></h6>
|
||||
<p>
|
||||
{{ request.user.profile.agency.email }}
|
||||
{{ request.user.profile.agency.agency_email }}
|
||||
</p>
|
||||
<p>
|
||||
{{ request.user.profile.agency.phone }}
|
||||
|
|
@ -26,9 +26,6 @@
|
|||
<p>
|
||||
<img class="img-profile" width="75%" src="{{ request.user.profile.agency.get_photo_url }}">
|
||||
</p>
|
||||
</div>
|
||||
{% if perms.users.agency_change %}
|
||||
<a href="{% url 'agency-manage' request.user.profile.agency.pk %}" class="btn btn-success">Agenturinformationen anpassen</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
{% extends "users/base.html" %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block content %}
|
||||
<div class="content-section">
|
||||
<!-- Für das Speichern der Bilder enctype -->
|
||||
<div class="col-7">
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<fieldset class="form-group">
|
||||
<legend class="border-bottom mb-4">
|
||||
Agenturinformationen bearbeiten
|
||||
</legend>
|
||||
<!-- FORMS LADEN -->
|
||||
{{ form|crispy }}
|
||||
</fieldset>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-success">Speichern</button>
|
||||
<a href="{% url 'agencyinfo' %}" class="btn">Abbrechen</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<!--
|
||||
|
||||
{% if active_link == 'cloud' %}
|
||||
<li class="nav-item active">
|
||||
{% else%}
|
||||
|
|
@ -136,7 +136,7 @@
|
|||
<span>Dateien</span>
|
||||
</a>
|
||||
</li>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -314,7 +314,7 @@
|
|||
<!-- MESSAGES -->
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert" id="message_{{forloop.counter}}">
|
||||
<div class="alert alert-{{ message.tags }} alert-dismissible fade show col-6" role="alert" id="message_{{forloop.counter}}">
|
||||
{{ message }}
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
|
|
@ -375,7 +375,8 @@
|
|||
</body>
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
function clearSF(){
|
||||
$("#searchcontent").empty();
|
||||
$("#searchcontent").hide();
|
||||
|
|
|
|||
|
|
@ -63,18 +63,41 @@ class UsersAddProfileForm(forms.ModelForm):
|
|||
# Formular zum hinzufügen neuer Agentur-Mitglieder
|
||||
class AgencyUpdateForm(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 = Agency
|
||||
labels = {
|
||||
"name" : "Agenturname",
|
||||
"inhaber" : "Inhaber",
|
||||
"street" : "Straße",
|
||||
"street" : "Straße und Hausnummer",
|
||||
"plz" : "PLZ",
|
||||
"city" : "Stadt",
|
||||
"email" : "E-Mail",
|
||||
"agency_email" : "E-Mail",
|
||||
"phone" : "Telefon",
|
||||
"agencypic" : "Agenturbild"
|
||||
}
|
||||
fields = ['name','inhaber','street', 'city', 'email', 'phone', 'agencypic']
|
||||
fields = ['name','inhaber','street', 'plz', 'city', 'agency_email', 'phone', 'agencypic', 'x', 'y', 'width', 'height', 'rotation']
|
||||
|
||||
def save(self):
|
||||
photo = super(AgencyUpdateForm, 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.agencypic)
|
||||
rotatet_image = image.rotate(rotation, expand=True)
|
||||
cropped_image = rotatet_image.crop((x, y, w+x, h+y))
|
||||
resized_image = cropped_image.resize((1500, 750), Image.ANTIALIAS)
|
||||
resized_image.save(photo.agencypic.path)
|
||||
return photo
|
||||
except:
|
||||
print("no photo")
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue