Commit fe7ba2456d7179456ac48743c0ec1cfc2cec19d4
1 parent
231898bc
Exists in
master
and in
3 other branches
Adjusts
Showing
4 changed files
with
13 additions
and
11 deletions
Show diff stats
mural/views.py
| ... | ... | @@ -41,9 +41,9 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): |
| 41 | 41 | 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))"}) |
| 42 | 42 | else: |
| 43 | 43 | if mines: |
| 44 | - 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) | |
| 44 | + 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) | |
| 45 | 45 | else: |
| 46 | - 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) | |
| 46 | + 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) | |
| 47 | 47 | |
| 48 | 48 | if showing: #Exclude ajax creation posts results |
| 49 | 49 | showing = showing.split(',') | ... | ... |
themes/models.py
| ... | ... | @@ -12,9 +12,9 @@ def validate_img_extension(value): |
| 12 | 12 | |
| 13 | 13 | class Themes(models.Model): |
| 14 | 14 | title = models.CharField(_("Title"), max_length = 200, default = "Projeto Amadeus") |
| 15 | - favicon = models.ImageField(verbose_name = _("Favicon"), blank = True, upload_to = 'themes/', default = 'favicon_amadeus.png', validators = [validate_img_extension]) | |
| 16 | - small_logo = models.ImageField(verbose_name = _("Small Logo"), blank = True, upload_to = 'themes/', default = 'logo_pequena_amadeus.png', validators = [validate_img_extension]) | |
| 17 | - large_logo = models.ImageField(verbose_name = _("Large Logo"), blank = True, upload_to = 'themes/', default = 'logo_grande_amadeus.png', validators = [validate_img_extension]) | |
| 15 | + favicon = models.ImageField(verbose_name = _("Favicon"), blank = True, null = True, upload_to = 'themes/', validators = [validate_img_extension]) | |
| 16 | + small_logo = models.ImageField(verbose_name = _("Small Logo"), blank = True, null = True, upload_to = 'themes/', validators = [validate_img_extension]) | |
| 17 | + large_logo = models.ImageField(verbose_name = _("Large Logo"), blank = True, null = True, upload_to = 'themes/', validators = [validate_img_extension]) | |
| 18 | 18 | footer_note = models.TextField(_("Footer Note"), blank = True) |
| 19 | 19 | css_style = models.CharField(_("Css Style"), max_length = 50, default = "green", choices = (("green", _('Green')), ("red", _('Red')), ("black", _('Black')))) |
| 20 | 20 | |
| ... | ... | @@ -28,7 +28,7 @@ class Themes(models.Model): |
| 28 | 28 | @property |
| 29 | 29 | def favicon_url(self): |
| 30 | 30 | if self.favicon and hasattr(self.favicon, 'url'): |
| 31 | - if path.exists(self.favicon.url): | |
| 31 | + if path.exists(self.favicon.path): | |
| 32 | 32 | return self.favicon.url |
| 33 | 33 | |
| 34 | 34 | return static('img/favicon_amadeus.png') |
| ... | ... | @@ -36,7 +36,7 @@ class Themes(models.Model): |
| 36 | 36 | @property |
| 37 | 37 | def small_logo_url(self): |
| 38 | 38 | if self.small_logo and hasattr(self.small_logo, 'url'): |
| 39 | - if path.exists(self.small_logo.url): | |
| 39 | + if path.exists(self.small_logo.path): | |
| 40 | 40 | return self.small_logo.url |
| 41 | 41 | |
| 42 | 42 | return static('img/logo_pequena_amadeus.png') |
| ... | ... | @@ -44,7 +44,7 @@ class Themes(models.Model): |
| 44 | 44 | @property |
| 45 | 45 | def large_logo_url(self): |
| 46 | 46 | if self.large_logo and hasattr(self.large_logo, 'url'): |
| 47 | - if path.exists(self.large_logo.url): | |
| 47 | + if path.exists(self.large_logo.path): | |
| 48 | 48 | return self.large_logo.url |
| 49 | 49 | |
| 50 | 50 | return static('img/logo_grande_amadeus.png') |
| 51 | 51 | \ No newline at end of file | ... | ... |
uploads/no_image.jpg
2.99 KB
users/models.py
| 1 | 1 | import re |
| 2 | 2 | |
| 3 | +from os import path | |
| 3 | 4 | from django.db import models |
| 4 | 5 | from django.core import validators |
| 5 | 6 | from django.core.exceptions import ValidationError |
| ... | ... | @@ -52,9 +53,10 @@ class User(AbstractBaseUser, PermissionsMixin): |
| 52 | 53 | @property |
| 53 | 54 | def image_url(self): |
| 54 | 55 | if self.image and hasattr(self.image, 'url'): |
| 55 | - return self.image.url | |
| 56 | - else: | |
| 57 | - return static('img/no_image.jpg') | |
| 56 | + if path.exists(self.image.path): | |
| 57 | + return self.image.url | |
| 58 | + | |
| 59 | + return static('img/no_image.jpg') | |
| 58 | 60 | |
| 59 | 61 | def is_admin(self): |
| 60 | 62 | if self.is_staff: | ... | ... |