diff --git a/mural/views.py b/mural/views.py index 282a9b5..08b2985 100644 --- a/mural/views.py +++ b/mural/views.py @@ -41,9 +41,9 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}) else: if mines: - general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).filter(favorites_post__isnull = False, mural_ptr__user = user) + general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).filter(favorites_post__isnull = False, favorites_post__user = user, mural_ptr__user = user) else: - general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).filter(favorites_post__isnull = False) + general = GeneralPost.objects.extra(select = {"most_recent": "greatest(last_update, (select max(mural_comment.last_update) from mural_comment where mural_comment.post_id = mural_generalpost.mural_ptr_id))"}).filter(favorites_post__isnull = False, favorites_post__user = user) if showing: #Exclude ajax creation posts results showing = showing.split(',') diff --git a/themes/models.py b/themes/models.py index eb21fef..3bf6e31 100644 --- a/themes/models.py +++ b/themes/models.py @@ -12,9 +12,9 @@ def validate_img_extension(value): class Themes(models.Model): title = models.CharField(_("Title"), max_length = 200, default = "Projeto Amadeus") - favicon = models.ImageField(verbose_name = _("Favicon"), blank = True, upload_to = 'themes/', default = 'favicon_amadeus.png', validators = [validate_img_extension]) - small_logo = models.ImageField(verbose_name = _("Small Logo"), blank = True, upload_to = 'themes/', default = 'logo_pequena_amadeus.png', validators = [validate_img_extension]) - large_logo = models.ImageField(verbose_name = _("Large Logo"), blank = True, upload_to = 'themes/', default = 'logo_grande_amadeus.png', validators = [validate_img_extension]) + favicon = models.ImageField(verbose_name = _("Favicon"), blank = True, null = True, upload_to = 'themes/', validators = [validate_img_extension]) + small_logo = models.ImageField(verbose_name = _("Small Logo"), blank = True, null = True, upload_to = 'themes/', validators = [validate_img_extension]) + large_logo = models.ImageField(verbose_name = _("Large Logo"), blank = True, null = True, upload_to = 'themes/', validators = [validate_img_extension]) footer_note = models.TextField(_("Footer Note"), blank = True) css_style = models.CharField(_("Css Style"), max_length = 50, default = "green", choices = (("green", _('Green')), ("red", _('Red')), ("black", _('Black')))) @@ -28,7 +28,7 @@ class Themes(models.Model): @property def favicon_url(self): if self.favicon and hasattr(self.favicon, 'url'): - if path.exists(self.favicon.url): + if path.exists(self.favicon.path): return self.favicon.url return static('img/favicon_amadeus.png') @@ -36,7 +36,7 @@ class Themes(models.Model): @property def small_logo_url(self): if self.small_logo and hasattr(self.small_logo, 'url'): - if path.exists(self.small_logo.url): + if path.exists(self.small_logo.path): return self.small_logo.url return static('img/logo_pequena_amadeus.png') @@ -44,7 +44,7 @@ class Themes(models.Model): @property def large_logo_url(self): if self.large_logo and hasattr(self.large_logo, 'url'): - if path.exists(self.large_logo.url): + if path.exists(self.large_logo.path): return self.large_logo.url return static('img/logo_grande_amadeus.png') \ No newline at end of file diff --git a/uploads/no_image.jpg b/uploads/no_image.jpg deleted file mode 100644 index 050c385..0000000 Binary files a/uploads/no_image.jpg and /dev/null differ diff --git a/users/models.py b/users/models.py index 3a7e47e..b596d47 100644 --- a/users/models.py +++ b/users/models.py @@ -1,5 +1,6 @@ import re +from os import path from django.db import models from django.core import validators from django.core.exceptions import ValidationError @@ -52,9 +53,10 @@ class User(AbstractBaseUser, PermissionsMixin): @property def image_url(self): if self.image and hasattr(self.image, 'url'): - return self.image.url - else: - return static('img/no_image.jpg') + if path.exists(self.image.path): + return self.image.url + + return static('img/no_image.jpg') def is_admin(self): if self.is_staff: -- libgit2 0.21.2