diff --git a/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_2x0Yin9.jpg b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_2x0Yin9.jpg new file mode 100644 index 0000000..68c3f15 Binary files /dev/null and b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_2x0Yin9.jpg differ diff --git a/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_9W87LTS_Q9DDWtn.jpg b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_9W87LTS_Q9DDWtn.jpg new file mode 100644 index 0000000..e675f4b Binary files /dev/null and b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_9W87LTS_Q9DDWtn.jpg differ diff --git a/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_LF6rJCu.jpg b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_LF6rJCu.jpg new file mode 100644 index 0000000..68c3f15 Binary files /dev/null and b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_LF6rJCu.jpg differ diff --git a/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_TvG0P8V.jpg b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_TvG0P8V.jpg new file mode 100644 index 0000000..e675f4b Binary files /dev/null and b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_TvG0P8V.jpg differ diff --git a/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_bPD8ep4.jpg b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_bPD8ep4.jpg new file mode 100644 index 0000000..e675f4b Binary files /dev/null and b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_bPD8ep4.jpg differ diff --git a/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_e1L1oOQ.jpg b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_e1L1oOQ.jpg new file mode 100644 index 0000000..e675f4b Binary files /dev/null and b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_e1L1oOQ.jpg differ diff --git a/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_sPNKusk.jpg b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_sPNKusk.jpg new file mode 100644 index 0000000..e675f4b Binary files /dev/null and b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_sPNKusk.jpg differ diff --git a/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_vwjiIeh.jpg b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_vwjiIeh.jpg new file mode 100644 index 0000000..e675f4b Binary files /dev/null and b/media/userprofilepics/0829d2ece9919052d3dc3dcd3aada422_vwjiIeh.jpg differ diff --git a/users/__pycache__/models.cpython-38.pyc b/users/__pycache__/models.cpython-38.pyc index df708c8..76bc66e 100644 Binary files a/users/__pycache__/models.cpython-38.pyc and b/users/__pycache__/models.cpython-38.pyc differ diff --git a/users/__pycache__/usersforms.cpython-38.pyc b/users/__pycache__/usersforms.cpython-38.pyc index 2559f8b..71fb9c8 100644 Binary files a/users/__pycache__/usersforms.cpython-38.pyc and b/users/__pycache__/usersforms.cpython-38.pyc differ diff --git a/users/__pycache__/views.cpython-38.pyc b/users/__pycache__/views.cpython-38.pyc index 79d49d9..9671f89 100644 Binary files a/users/__pycache__/views.cpython-38.pyc and b/users/__pycache__/views.cpython-38.pyc differ diff --git a/users/models.py b/users/models.py index 01d0261..da611b3 100644 --- a/users/models.py +++ b/users/models.py @@ -31,7 +31,7 @@ class Agency(models.Model): city = models.CharField(default="", max_length=200, blank=True) email = models.EmailField(default="", 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): return f'{self.name}' @@ -84,7 +84,7 @@ 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='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) @@ -100,26 +100,27 @@ class Profile(models.Model): def save(self, **kwargs): super().save() - img = Image.open(self.image.path) - - # Bildspeichergröße - #if(img.height > 300 or img.width > 300): - # output_size = (300,300) - # img.thumbnail(output_size) - # img.save(self.image.path) - baseheight = 560 - hpercent = (baseheight / float(img.size[1])) - wsize = int((float(img.size[0]) * float(hpercent))) - img = img.resize((wsize, baseheight), Image.ANTIALIAS) - img.save(self.image.path) + if self.image: + img = Image.open(self.image.path) + # Bildspeichergröße + if(img.height > 300 or img.width > 300): + output_size = (300,300) + img.thumbnail(output_size) + img.save(self.image.path) + baseheight = 560 + hpercent = (baseheight / float(img.size[1])) + wsize = int((float(img.size[0]) * float(hpercent))) + img = img.resize((wsize, baseheight), Image.ANTIALIAS) + img.save(self.image.path) + @property def get_photo_url(self): if self.image and hasattr(self.image, 'url'): return self.image.url else: return "/media/userprofilepics/default.jpg" - + # PERMISSIONS - Über alle Modelle hinweg, in der url.py wird dann die route verhindert! # Im template: if perms.users.PERMISSION class Meta: diff --git a/users/usersforms.py b/users/usersforms.py index 49afb06..2929092 100644 --- a/users/usersforms.py +++ b/users/usersforms.py @@ -37,15 +37,6 @@ class UsersAddProfileForm(forms.ModelForm): } 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 class AgencyUpdateForm(forms.ModelForm): diff --git a/users/views.py b/users/views.py index 2ef9fde..f06b1fe 100644 --- a/users/views.py +++ b/users/views.py @@ -219,17 +219,14 @@ def ProfileUpdateView(request, pk): prof_user = User.objects.get(profile__pk=pk) 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) if profileform_form.is_valid(): - - print(profileform_form) - profileform_form.save() - #prename = request.user.first_name - #name = request.user.last_name - #messages.success(request, f'Daten für {prename} {name} aktualisiert!') + prename = request.user.first_name + name = request.user.last_name + messages.success(request, f'Daten für {prename} {name} aktualisiert!') # Daten neu laden und nicht die "Mächten sie die Daten speichern...?" return redirect('users-management')