mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add is_in_sas field, to perform queries on it
This commit is contained in:
@ -14,11 +14,6 @@ class Picture(SithFile):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
@property
|
||||
def is_in_sas(self):
|
||||
sas = SithFile.objects.filter(id=settings.SITH_SAS_ROOT_DIR_ID).first()
|
||||
return sas in self.get_parent_list()
|
||||
|
||||
@property
|
||||
def is_vertical(self):
|
||||
im = Image.open(BytesIO(self.file.read()))
|
||||
@ -79,11 +74,6 @@ class Album(SithFile):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
@property
|
||||
def is_in_sas(self):
|
||||
sas = SithFile.objects.filter(id=settings.SITH_SAS_ROOT_DIR_ID).first()
|
||||
return sas in self.get_parent_list()
|
||||
|
||||
def can_be_edited_by(self, user):
|
||||
return user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID)
|
||||
|
||||
|
@ -33,7 +33,7 @@ class SASForm(forms.Form):
|
||||
album.save()
|
||||
except Exception as e:
|
||||
self.add_error(None, _("Error creating album %(album)s: %(msg)s") %
|
||||
{'album': self.cleaned_data['album_name'], 'msg': str(e.message)})
|
||||
{'album': self.cleaned_data['album_name'], 'msg': repr(e)})
|
||||
for f in files:
|
||||
new_file = Picture(parent=parent, name=f.name, file=f, owner=owner, mime_type=f.content_type, size=f._size,
|
||||
is_folder=False, is_moderated=automodere)
|
||||
@ -189,7 +189,7 @@ class ModerationView(TemplateView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(ModerationView, self).get_context_data(**kwargs)
|
||||
kwargs['pictures'] = [p for p in Picture.objects.filter(is_moderated=False).order_by('id') if p.is_in_sas]
|
||||
kwargs['pictures'] = Picture.objects.filter(is_moderated=False, is_in_sas=True).order_by('id')
|
||||
return kwargs
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user