Fotobug behoben
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
|
@ -31,7 +31,7 @@ class Agency(models.Model):
|
||||||
city = models.CharField(default="", max_length=200, blank=True)
|
city = models.CharField(default="", max_length=200, blank=True)
|
||||||
email = models.EmailField(default="", blank=True)
|
email = models.EmailField(default="", blank=True)
|
||||||
phone = models.CharField(default="", max_length=20, blank=True)
|
phone = models.CharField(default="", max_length=20, blank=True)
|
||||||
agencypic = models.ImageField(default='default.jpg', upload_to='agencymain', blank=True, null="default.jpg")
|
agencypic = models.ImageField(default='default.jpg', upload_to='agencymain', blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.name}'
|
return f'{self.name}'
|
||||||
|
|
@ -84,7 +84,7 @@ class Profile(models.Model):
|
||||||
func = models.CharField(choices=agency_task, default="", max_length=50)
|
func = models.CharField(choices=agency_task, default="", max_length=50)
|
||||||
# Wenn dieses Profil gelöscht wird, wird NICHT die Agency geslöscht
|
# Wenn dieses Profil gelöscht wird, wird NICHT die Agency geslöscht
|
||||||
agency = models.ForeignKey(Agency, on_delete=models.PROTECT)
|
agency = models.ForeignKey(Agency, on_delete=models.PROTECT)
|
||||||
image = models.ImageField(default='default.jpg', upload_to='userprofilepics', blank=True, null="default.jpg")
|
image = models.ImageField(default='default.jpg', upload_to='userprofilepics', blank=True)
|
||||||
compfunc = models.CharField(max_length=60, blank=True)
|
compfunc = models.CharField(max_length=60, blank=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -100,18 +100,19 @@ class Profile(models.Model):
|
||||||
|
|
||||||
def save(self, **kwargs):
|
def save(self, **kwargs):
|
||||||
super().save()
|
super().save()
|
||||||
img = Image.open(self.image.path)
|
if self.image:
|
||||||
|
img = Image.open(self.image.path)
|
||||||
|
|
||||||
# Bildspeichergröße
|
# Bildspeichergröße
|
||||||
#if(img.height > 300 or img.width > 300):
|
if(img.height > 300 or img.width > 300):
|
||||||
# output_size = (300,300)
|
output_size = (300,300)
|
||||||
# img.thumbnail(output_size)
|
img.thumbnail(output_size)
|
||||||
# img.save(self.image.path)
|
img.save(self.image.path)
|
||||||
baseheight = 560
|
baseheight = 560
|
||||||
hpercent = (baseheight / float(img.size[1]))
|
hpercent = (baseheight / float(img.size[1]))
|
||||||
wsize = int((float(img.size[0]) * float(hpercent)))
|
wsize = int((float(img.size[0]) * float(hpercent)))
|
||||||
img = img.resize((wsize, baseheight), Image.ANTIALIAS)
|
img = img.resize((wsize, baseheight), Image.ANTIALIAS)
|
||||||
img.save(self.image.path)
|
img.save(self.image.path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_photo_url(self):
|
def get_photo_url(self):
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,6 @@ class UsersAddProfileForm(forms.ModelForm):
|
||||||
}
|
}
|
||||||
fields = ['phoneland','phonemobile','func', 'compfunc', 'image']
|
fields = ['phoneland','phonemobile','func', 'compfunc', 'image']
|
||||||
|
|
||||||
#class UsersAddProfileFormParents(forms.ModelForm):
|
|
||||||
|
|
||||||
|
|
||||||
# def __init__(self, user, *args, **kwargs):
|
|
||||||
# super().__init__(*args, **kwargs)
|
|
||||||
# possibleUsers = Profile
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Formular zum hinzufügen neuer Agentur-Mitglieder
|
# Formular zum hinzufügen neuer Agentur-Mitglieder
|
||||||
class AgencyUpdateForm(forms.ModelForm):
|
class AgencyUpdateForm(forms.ModelForm):
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,17 +219,14 @@ def ProfileUpdateView(request, pk):
|
||||||
prof_user = User.objects.get(profile__pk=pk)
|
prof_user = User.objects.get(profile__pk=pk)
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
profileform_form = UsersAddProfileForm(request.POST, instance=prof_user.profile)
|
profileform_form = UsersAddProfileForm(request.POST, request.FILES, instance=prof_user.profile)
|
||||||
#profileform_parents = UsersAddProfileFormParents(request.POST, instance=request.user)
|
#profileform_parents = UsersAddProfileFormParents(request.POST, instance=request.user)
|
||||||
|
|
||||||
if profileform_form.is_valid():
|
if profileform_form.is_valid():
|
||||||
|
|
||||||
print(profileform_form)
|
|
||||||
|
|
||||||
profileform_form.save()
|
profileform_form.save()
|
||||||
#prename = request.user.first_name
|
prename = request.user.first_name
|
||||||
#name = request.user.last_name
|
name = request.user.last_name
|
||||||
#messages.success(request, f'Daten für {prename} {name} aktualisiert!')
|
messages.success(request, f'Daten für {prename} {name} aktualisiert!')
|
||||||
# Daten neu laden und nicht die "Mächten sie die Daten speichern...?"
|
# Daten neu laden und nicht die "Mächten sie die Daten speichern...?"
|
||||||
return redirect('users-management')
|
return redirect('users-management')
|
||||||
|
|
||||||
|
|
|
||||||