Commit fe7ba2456d7179456ac48743c0ec1cfc2cec19d4

Authored by Zambom
1 parent 231898bc

Adjusts

mural/views.py
@@ -41,9 +41,9 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView): @@ -41,9 +41,9 @@ class GeneralIndex(LoginRequiredMixin, generic.ListView):
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))"}) 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 else: 42 else:
43 if mines: 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 else: 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 if showing: #Exclude ajax creation posts results 48 if showing: #Exclude ajax creation posts results
49 showing = showing.split(',') 49 showing = showing.split(',')
themes/models.py
@@ -12,9 +12,9 @@ def validate_img_extension(value): @@ -12,9 +12,9 @@ def validate_img_extension(value):
12 12
13 class Themes(models.Model): 13 class Themes(models.Model):
14 title = models.CharField(_("Title"), max_length = 200, default = "Projeto Amadeus") 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 footer_note = models.TextField(_("Footer Note"), blank = True) 18 footer_note = models.TextField(_("Footer Note"), blank = True)
19 css_style = models.CharField(_("Css Style"), max_length = 50, default = "green", choices = (("green", _('Green')), ("red", _('Red')), ("black", _('Black')))) 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,7 +28,7 @@ class Themes(models.Model):
28 @property 28 @property
29 def favicon_url(self): 29 def favicon_url(self):
30 if self.favicon and hasattr(self.favicon, 'url'): 30 if self.favicon and hasattr(self.favicon, 'url'):
31 - if path.exists(self.favicon.url): 31 + if path.exists(self.favicon.path):
32 return self.favicon.url 32 return self.favicon.url
33 33
34 return static('img/favicon_amadeus.png') 34 return static('img/favicon_amadeus.png')
@@ -36,7 +36,7 @@ class Themes(models.Model): @@ -36,7 +36,7 @@ class Themes(models.Model):
36 @property 36 @property
37 def small_logo_url(self): 37 def small_logo_url(self):
38 if self.small_logo and hasattr(self.small_logo, 'url'): 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 return self.small_logo.url 40 return self.small_logo.url
41 41
42 return static('img/logo_pequena_amadeus.png') 42 return static('img/logo_pequena_amadeus.png')
@@ -44,7 +44,7 @@ class Themes(models.Model): @@ -44,7 +44,7 @@ class Themes(models.Model):
44 @property 44 @property
45 def large_logo_url(self): 45 def large_logo_url(self):
46 if self.large_logo and hasattr(self.large_logo, 'url'): 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 return self.large_logo.url 48 return self.large_logo.url
49 49
50 return static('img/logo_grande_amadeus.png') 50 return static('img/logo_grande_amadeus.png')
51 \ No newline at end of file 51 \ No newline at end of file
uploads/no_image.jpg

2.99 KB

users/models.py
1 import re 1 import re
2 2
  3 +from os import path
3 from django.db import models 4 from django.db import models
4 from django.core import validators 5 from django.core import validators
5 from django.core.exceptions import ValidationError 6 from django.core.exceptions import ValidationError
@@ -52,9 +53,10 @@ class User(AbstractBaseUser, PermissionsMixin): @@ -52,9 +53,10 @@ class User(AbstractBaseUser, PermissionsMixin):
52 @property 53 @property
53 def image_url(self): 54 def image_url(self):
54 if self.image and hasattr(self.image, 'url'): 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 def is_admin(self): 61 def is_admin(self):
60 if self.is_staff: 62 if self.is_staff: