From 14083b9e08b543980588328e62b25b4b52d1742a Mon Sep 17 00:00:00 2001 From: Zambom Date: Sun, 27 Aug 2017 21:10:11 -0300 Subject: [PATCH] Fixing bugs involving password in users module and image related in user deletion --- amadeus/locale/pt_BR/LC_MESSAGES/django.po | 2 +- analytics/locale/pt_BR/LC_MESSAGES/django.po | 2 +- api/locale/pt_BR/LC_MESSAGES/django.po | 2 +- bulletin/locale/pt_BR/LC_MESSAGES/django.po | 2 +- categories/locale/pt_BR/LC_MESSAGES/django.po | 2 +- chat/locale/pt_BR/LC_MESSAGES/django.po | 2 +- dashboards/locale/pt_BR/LC_MESSAGES/django.po | 2 +- file_link/locale/pt_BR/LC_MESSAGES/django.po | 2 +- goals/locale/pt_BR/LC_MESSAGES/django.po | 2 +- links/locale/pt_BR/LC_MESSAGES/django.po | 2 +- log/locale/pt_BR/LC_MESSAGES/django.po | 2 +- mailsender/locale/pt_BR/LC_MESSAGES/django.po | 2 +- mural/locale/pt_BR/LC_MESSAGES/django.po | 2 +- news/locale/pt_BR/LC_MESSAGES/django.po | 2 +- notifications/locale/pt_BR/LC_MESSAGES/django.po | 2 +- pdf_file/locale/pt_BR/LC_MESSAGES/django.po | 2 +- pendencies/locale/pt_BR/LC_MESSAGES/django.po | 2 +- reports/locale/pt_BR/LC_MESSAGES/django.po | 2 +- security/locale/pt_BR/LC_MESSAGES/django.po | 2 +- students_group/locale/pt_BR/LC_MESSAGES/django.po | 2 +- subjects/locale/pt_BR/LC_MESSAGES/django.po | 2 +- themes/locale/pt_BR/LC_MESSAGES/django.po | 2 +- topics/locale/pt_BR/LC_MESSAGES/django.po | 6 +++--- users/forms.py | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------- users/locale/pt_BR/LC_MESSAGES/django.po | 74 +++++++++++++++++++++++++++++++++++++++----------------------------------- users/views.py | 14 +++++++++++--- webconference/locale/pt_BR/LC_MESSAGES/django.po | 2 +- webpage/locale/pt_BR/LC_MESSAGES/django.po | 2 +- youtube_video/locale/pt_BR/LC_MESSAGES/django.po | 2 +- 29 files changed, 153 insertions(+), 124 deletions(-) diff --git a/amadeus/locale/pt_BR/LC_MESSAGES/django.po b/amadeus/locale/pt_BR/LC_MESSAGES/django.po index 247f7d3..3a1d003 100644 --- a/amadeus/locale/pt_BR/LC_MESSAGES/django.po +++ b/amadeus/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/analytics/locale/pt_BR/LC_MESSAGES/django.po b/analytics/locale/pt_BR/LC_MESSAGES/django.po index fd0a0a2..09f414d 100644 --- a/analytics/locale/pt_BR/LC_MESSAGES/django.po +++ b/analytics/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/api/locale/pt_BR/LC_MESSAGES/django.po b/api/locale/pt_BR/LC_MESSAGES/django.po index 9843828..620fcba 100644 --- a/api/locale/pt_BR/LC_MESSAGES/django.po +++ b/api/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/bulletin/locale/pt_BR/LC_MESSAGES/django.po b/bulletin/locale/pt_BR/LC_MESSAGES/django.po index e5abfe9..8bd4127 100644 --- a/bulletin/locale/pt_BR/LC_MESSAGES/django.po +++ b/bulletin/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/categories/locale/pt_BR/LC_MESSAGES/django.po b/categories/locale/pt_BR/LC_MESSAGES/django.po index 3540a7b..f2602d6 100644 --- a/categories/locale/pt_BR/LC_MESSAGES/django.po +++ b/categories/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/chat/locale/pt_BR/LC_MESSAGES/django.po b/chat/locale/pt_BR/LC_MESSAGES/django.po index db0ff82..461f120 100644 --- a/chat/locale/pt_BR/LC_MESSAGES/django.po +++ b/chat/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/dashboards/locale/pt_BR/LC_MESSAGES/django.po b/dashboards/locale/pt_BR/LC_MESSAGES/django.po index cb961b0..353cc24 100644 --- a/dashboards/locale/pt_BR/LC_MESSAGES/django.po +++ b/dashboards/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/file_link/locale/pt_BR/LC_MESSAGES/django.po b/file_link/locale/pt_BR/LC_MESSAGES/django.po index e16bd48..99fe684 100644 --- a/file_link/locale/pt_BR/LC_MESSAGES/django.po +++ b/file_link/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/goals/locale/pt_BR/LC_MESSAGES/django.po b/goals/locale/pt_BR/LC_MESSAGES/django.po index 6400e4e..d2721ff 100644 --- a/goals/locale/pt_BR/LC_MESSAGES/django.po +++ b/goals/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/links/locale/pt_BR/LC_MESSAGES/django.po b/links/locale/pt_BR/LC_MESSAGES/django.po index 8d47ffb..01b7be8 100644 --- a/links/locale/pt_BR/LC_MESSAGES/django.po +++ b/links/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/log/locale/pt_BR/LC_MESSAGES/django.po b/log/locale/pt_BR/LC_MESSAGES/django.po index 801718d..7c76da4 100644 --- a/log/locale/pt_BR/LC_MESSAGES/django.po +++ b/log/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/mailsender/locale/pt_BR/LC_MESSAGES/django.po b/mailsender/locale/pt_BR/LC_MESSAGES/django.po index d297ea9..58711b6 100644 --- a/mailsender/locale/pt_BR/LC_MESSAGES/django.po +++ b/mailsender/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/mural/locale/pt_BR/LC_MESSAGES/django.po b/mural/locale/pt_BR/LC_MESSAGES/django.po index 6edd8f9..b18d062 100644 --- a/mural/locale/pt_BR/LC_MESSAGES/django.po +++ b/mural/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/news/locale/pt_BR/LC_MESSAGES/django.po b/news/locale/pt_BR/LC_MESSAGES/django.po index 0375c35..306e84b 100644 --- a/news/locale/pt_BR/LC_MESSAGES/django.po +++ b/news/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/notifications/locale/pt_BR/LC_MESSAGES/django.po b/notifications/locale/pt_BR/LC_MESSAGES/django.po index 7fdc87d..2229043 100644 --- a/notifications/locale/pt_BR/LC_MESSAGES/django.po +++ b/notifications/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/pdf_file/locale/pt_BR/LC_MESSAGES/django.po b/pdf_file/locale/pt_BR/LC_MESSAGES/django.po index 76d4287..3d2c2a8 100644 --- a/pdf_file/locale/pt_BR/LC_MESSAGES/django.po +++ b/pdf_file/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/pendencies/locale/pt_BR/LC_MESSAGES/django.po b/pendencies/locale/pt_BR/LC_MESSAGES/django.po index e1bb2d5..994f7f5 100644 --- a/pendencies/locale/pt_BR/LC_MESSAGES/django.po +++ b/pendencies/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/reports/locale/pt_BR/LC_MESSAGES/django.po b/reports/locale/pt_BR/LC_MESSAGES/django.po index ef68d6b..52d126a 100644 --- a/reports/locale/pt_BR/LC_MESSAGES/django.po +++ b/reports/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/security/locale/pt_BR/LC_MESSAGES/django.po b/security/locale/pt_BR/LC_MESSAGES/django.po index fbc6f64..7f77621 100644 --- a/security/locale/pt_BR/LC_MESSAGES/django.po +++ b/security/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/students_group/locale/pt_BR/LC_MESSAGES/django.po b/students_group/locale/pt_BR/LC_MESSAGES/django.po index d670de7..344a5b1 100644 --- a/students_group/locale/pt_BR/LC_MESSAGES/django.po +++ b/students_group/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/subjects/locale/pt_BR/LC_MESSAGES/django.po b/subjects/locale/pt_BR/LC_MESSAGES/django.po index 51840bf..1b48b92 100644 --- a/subjects/locale/pt_BR/LC_MESSAGES/django.po +++ b/subjects/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/themes/locale/pt_BR/LC_MESSAGES/django.po b/themes/locale/pt_BR/LC_MESSAGES/django.po index dac73ca..83c2a5c 100644 --- a/themes/locale/pt_BR/LC_MESSAGES/django.po +++ b/themes/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/topics/locale/pt_BR/LC_MESSAGES/django.po b/topics/locale/pt_BR/LC_MESSAGES/django.po index 9213edb..99e8acc 100644 --- a/topics/locale/pt_BR/LC_MESSAGES/django.po +++ b/topics/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,11 +18,11 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: topics/forms.py:28 +#: topics/forms.py:30 topics/forms.py:47 msgid "This subject already has a repository" msgstr "Esse assunto já possui um repositório" -#: topics/forms.py:30 +#: topics/forms.py:49 msgid "This subject already has a topic with this name" msgstr "Esse assunto já possui um tópico com esse nome" diff --git a/users/forms.py b/users/forms.py index 53cc9a3..e36f26d 100644 --- a/users/forms.py +++ b/users/forms.py @@ -46,72 +46,89 @@ class Validation(forms.ModelForm): return image - def clean_password2(self): - password = self.cleaned_data.get("new_password") - password2 = self.cleaned_data.get("password2") + def clean_new_password(self): + password = self.cleaned_data.get('new_password') + + if self.is_edit and len(password) == 0: + return password - if password and password2 and password != password2: - self._errors['password2'] = [_('The confirmation password is incorrect.')] + if len(password) == 0: + self._errors['new_password'] = [_('You must define a password.')] return ValueError + return password + + def clean_password2(self): + password = self.cleaned_data.get("new_password", None) + password2 = self.cleaned_data.get("password2", None) + + if self.is_edit and len(password) == 0: + return password2 + + if not password is None and password != ValueError: + if not password2 is None and password != password2: + self._errors['password2'] = [_('The confirmation password is incorrect.')] + + return ValueError + return password2 class RegisterUserForm(Validation): - new_password = forms.CharField(label=_('Password'), widget = forms.PasswordInput(render_value = True, attrs = {'placeholder': _('Password *')})) - password2 = forms.CharField(label = _('Confirm Password'), widget = forms.PasswordInput(render_value = True, attrs = {'placeholder': _('Confirm Password *')})) + new_password = forms.CharField(label=_('Password'), widget = forms.PasswordInput(render_value = True, attrs = {'placeholder': _('Password *')})) + password2 = forms.CharField(label = _('Confirm Password'), widget = forms.PasswordInput(render_value = True, attrs = {'placeholder': _('Confirm Password *')})) - is_edit = False + is_edit = False #Cropping image - x = forms.FloatField(widget=forms.HiddenInput(),required=False) - y = forms.FloatField(widget=forms.HiddenInput(),required=False) - width = forms.FloatField(widget=forms.HiddenInput(),required=False) - height = forms.FloatField(widget=forms.HiddenInput(),required=False) - - - def save(self, commit=True): - super(RegisterUserForm, self).save(commit=False) - self.deletepath = "" - - x = self.cleaned_data.get('x') - y = self.cleaned_data.get('y') - w = self.cleaned_data.get('width') - h = self.cleaned_data.get('height') - - if self.instance.image : - image = Image.open(self.instance.image) - if not x is None: - cropped_image = image.crop((x, y, w+x, h+y)) - resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS) - - folder_path = join(settings.MEDIA_ROOT, 'users') - #check if the folder already exists - if not os.path.isdir(folder_path): - os.makedirs(folder_path) - - if ("users" not in self.instance.image.path): - self.deletepath = self.instance.image.path - - resized_image.save(self.instance.image.path) - - self.instance.set_password(self.cleaned_data['new_password']) - - self.instance.save() - if (self.deletepath): - os.remove(self.deletepath) - return self.instance - - class Meta: - model = User - fields = ['email', 'username', 'last_name', 'social_name', 'image', 'show_email', 'x', 'y', 'width', 'height',] - widgets = { - 'email': forms.EmailInput(attrs = {'placeholder': _('Email *')}), - 'username': forms.TextInput(attrs = {'placeholder': _('Name *')}), - 'last_name': forms.TextInput(attrs = {'placeholder': _('Last Name *')}), - 'social_name': forms.TextInput(attrs = {'placeholder': _('Social Name')}), + x = forms.FloatField(widget=forms.HiddenInput(),required=False) + y = forms.FloatField(widget=forms.HiddenInput(),required=False) + width = forms.FloatField(widget=forms.HiddenInput(),required=False) + height = forms.FloatField(widget=forms.HiddenInput(),required=False) + + + def save(self, commit=True): + super(RegisterUserForm, self).save(commit=False) + self.deletepath = "" + + x = self.cleaned_data.get('x') + y = self.cleaned_data.get('y') + w = self.cleaned_data.get('width') + h = self.cleaned_data.get('height') + + if self.instance.image : + image = Image.open(self.instance.image) + if not x is None: + cropped_image = image.crop((x, y, w+x, h+y)) + resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS) + + folder_path = join(settings.MEDIA_ROOT, 'users') + #check if the folder already exists + if not os.path.isdir(folder_path): + os.makedirs(folder_path) + + if ("users" not in self.instance.image.path): + self.deletepath = self.instance.image.path + + resized_image.save(self.instance.image.path) + + self.instance.set_password(self.cleaned_data['new_password']) + + self.instance.save() + if (self.deletepath): + os.remove(self.deletepath) + return self.instance + + class Meta: + model = User + fields = ['email', 'username', 'last_name', 'social_name', 'image', 'show_email', 'x', 'y', 'width', 'height',] + widgets = { + 'email': forms.EmailInput(attrs = {'placeholder': _('Email *')}), + 'username': forms.TextInput(attrs = {'placeholder': _('Name *')}), + 'last_name': forms.TextInput(attrs = {'placeholder': _('Last Name *')}), + 'social_name': forms.TextInput(attrs = {'placeholder': _('Social Name')}), 'image': ResubmitFileWidget(attrs={'accept':'image/*'}), - } + } class ProfileForm(Validation): is_edit = True @@ -137,7 +154,7 @@ class ProfileForm(Validation): resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS) folder_path = join(settings.MEDIA_ROOT, 'users') - #check if the folder already exists + #check if the folder already exists if not os.path.isdir(folder_path): os.makedirs(folder_path) @@ -148,7 +165,7 @@ class ProfileForm(Validation): self.instance.save() if (self.deletepath): - os.remove(self.deletepath) + os.remove(self.deletepath) return self.instance class Meta: @@ -197,7 +214,7 @@ class UserForm(Validation): resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS) folder_path = join(settings.MEDIA_ROOT, 'users') - #check if the folder already exists + #check if the folder already exists if not os.path.isdir(folder_path): os.makedirs(folder_path) diff --git a/users/locale/pt_BR/LC_MESSAGES/django.po b/users/locale/pt_BR/LC_MESSAGES/django.po index d416fdd..ba4d92c 100644 --- a/users/locale/pt_BR/LC_MESSAGES/django.po +++ b/users/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,7 +18,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: users/forms.py:28 users/forms.py:33 users/forms.py:279 +#: users/forms.py:28 users/forms.py:33 users/forms.py:296 msgid "You must insert an email address" msgstr "Você deve inserir um endereço de email" @@ -26,60 +26,64 @@ msgstr "Você deve inserir um endereço de email" msgid "The image is too large. It should have less than 2MB." msgstr "A imagem é muito grande. Ela deve conter menos de 2MB." -#: users/forms.py:54 +#: users/forms.py:56 +msgid "You must define a password." +msgstr "Você deve definir uma senha." + +#: users/forms.py:71 msgid "The confirmation password is incorrect." msgstr "A confirmação de senha está incorreta." -#: users/forms.py:61 users/forms.py:175 users/templates/users/login.html:52 +#: users/forms.py:78 users/forms.py:192 users/templates/users/login.html:52 msgid "Password" msgstr "Senha" -#: users/forms.py:61 +#: users/forms.py:78 msgid "Password *" msgstr "Senha *" -#: users/forms.py:62 users/forms.py:176 users/forms.py:236 users/forms.py:292 +#: users/forms.py:79 users/forms.py:193 users/forms.py:253 users/forms.py:309 msgid "Confirm Password" msgstr "Confirmação de Senha" -#: users/forms.py:62 +#: users/forms.py:79 msgid "Confirm Password *" msgstr "Confirmação de Senha *" -#: users/forms.py:109 +#: users/forms.py:126 msgid "Email *" msgstr "Email *" -#: users/forms.py:110 +#: users/forms.py:127 msgid "Name *" msgstr "Nome *" -#: users/forms.py:111 +#: users/forms.py:128 msgid "Last Name *" msgstr "Sobrenome *" -#: users/forms.py:112 users/models.py:31 +#: users/forms.py:129 users/models.py:31 msgid "Social Name" msgstr "Nome Social" -#: users/forms.py:235 users/forms.py:291 +#: users/forms.py:252 users/forms.py:308 msgid "New Password" msgstr "Nova Senha" -#: users/forms.py:242 +#: users/forms.py:259 msgid "The value inputed does not match with your actual password." msgstr "O valor inserido não corresponde à sua senha atual." -#: users/forms.py:263 +#: users/forms.py:280 msgid "Actual Password" msgstr "Senha Atual" -#: users/forms.py:270 users/templates/users/list.html:56 +#: users/forms.py:287 users/templates/users/list.html:56 #: users/templates/users/login.html:47 users/templates/users/search.html:47 msgid "Email" msgstr "Email" -#: users/forms.py:284 +#: users/forms.py:301 msgid "You must insert a valid email address" msgstr "Você deve inserir um endereço de email válido" @@ -200,7 +204,7 @@ msgstr "Deletar" msgid "Are you sure you want delete your account?" msgstr "Tem certeza que deseja deletar sua conta?" -#: users/templates/users/forgot_password.html:39 users/views.py:391 +#: users/templates/users/forgot_password.html:39 users/views.py:399 msgid "Forgot Password" msgstr "Esqueceu Senha" @@ -251,7 +255,7 @@ msgstr "Entre com a sua conta para continuar" msgid "Log in" msgstr "Entrar" -#: users/templates/users/login.html:66 users/views.py:365 +#: users/templates/users/login.html:66 users/views.py:373 msgid "Sign Up" msgstr "Cadastrar" @@ -349,39 +353,39 @@ msgstr "" "Não é possível deletar a conta. O usuário está vinculado com uma ou mais " "funções (administrador, coordenador, professor ou estudante) no sistema." -#: users/views.py:259 +#: users/views.py:267 msgid "Delete Account" msgstr "Remover Conta" -#: users/views.py:303 +#: users/views.py:311 msgid "Password changed successfully!" msgstr "Senha alterada com sucesso!" -#: users/views.py:309 +#: users/views.py:317 msgid "Change Password" msgstr "Alterar Senha" -#: users/views.py:327 +#: users/views.py:335 msgid "Profile" msgstr "Perfil" -#: users/views.py:346 +#: users/views.py:354 msgid "Update Profile" msgstr "Atualizar Perfil" -#: users/views.py:352 +#: users/views.py:360 msgid "Profile edited successfully!" msgstr "Perfil editado com sucesso!" -#: users/views.py:372 +#: users/views.py:380 msgid "User successfully registered!" msgstr "Usuário cadastrado com sucesso!" -#: users/views.py:410 +#: users/views.py:418 msgid "Recover Password" msgstr "Recuperar Senha" -#: users/views.py:446 +#: users/views.py:454 msgid "" "Soon you'll receive an email with instructions to set your new password. If " "you don't receive it in 24 hours, please check your spam box." @@ -389,34 +393,34 @@ msgstr "" "Em breve você receberá um email com instruções para cadastrar sua nova " "senha. Se você não recebê-lo em 24 hhoras, por favor olhe sua caixa de spam." -#: users/views.py:449 +#: users/views.py:457 msgid "No user is associated with this email address" msgstr "Nenhum usuário associado com esse endereço de email." -#: users/views.py:462 +#: users/views.py:470 msgid "Reset Password" msgstr "Recuperar Senha" -#: users/views.py:484 +#: users/views.py:492 msgid "Password reset successfully." msgstr "Senha alterada com sucesso!" -#: users/views.py:488 +#: users/views.py:496 msgid "We were not able to reset your password." msgstr "Não foi possível restaurar sua senha" -#: users/views.py:491 +#: users/views.py:499 msgid "The reset password link is no longer valid." msgstr "O link para restaurar senha não está mais válido." -#: users/views.py:497 +#: users/views.py:505 msgid "Log In" msgstr "Entrar" -#: users/views.py:533 +#: users/views.py:541 msgid "System under maintenance. Try again later" msgstr "Sistema em manutenção. Tente novamente mais tarde" -#: users/views.py:535 +#: users/views.py:543 msgid "E-mail or password are incorrect." msgstr "Email ou senha incorretos." diff --git a/users/views.py b/users/views.py index 966b48c..d71a75f 100644 --- a/users/views.py +++ b/users/views.py @@ -242,12 +242,20 @@ class DeleteView(braces_mixins.LoginRequiredMixin, LogMixin, generic.DeleteView) redirect_url = redirect(error_url) else: self.log_context['dependencies'] = False - image_path_to_delete = user.image.path + + if user.image: + image_path_to_delete = user.image.path + else: + image_path_to_delete = None + user.delete() messages.success(self.request, success_msg) - #deleting the user image - os.remove(image_path_to_delete) + + if not image_path_to_delete is None: + #deleting the user image + os.remove(image_path_to_delete) + redirect_url = redirect(success_url) super(DeleteView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) diff --git a/webconference/locale/pt_BR/LC_MESSAGES/django.po b/webconference/locale/pt_BR/LC_MESSAGES/django.po index 7dc3090..d63f8c4 100644 --- a/webconference/locale/pt_BR/LC_MESSAGES/django.po +++ b/webconference/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/webpage/locale/pt_BR/LC_MESSAGES/django.po b/webpage/locale/pt_BR/LC_MESSAGES/django.po index b9701f9..63a813c 100644 --- a/webpage/locale/pt_BR/LC_MESSAGES/django.po +++ b/webpage/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/youtube_video/locale/pt_BR/LC_MESSAGES/django.po b/youtube_video/locale/pt_BR/LC_MESSAGES/django.po index 6b8e0fa..2ef78bb 100644 --- a/youtube_video/locale/pt_BR/LC_MESSAGES/django.po +++ b/youtube_video/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-23 23:53-0300\n" +"POT-Creation-Date: 2017-08-27 21:08-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -- libgit2 0.21.2