mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Huge performance improvement in SAS, miss the album thumbnail in most cases
This commit is contained in:
parent
4a7df31f5e
commit
9f35f74082
@ -24,13 +24,13 @@ class Picture(SithFile):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def can_be_edited_by(self, user):
|
def can_be_edited_by(self, user):
|
||||||
file = SithFile.objects.filter(id=self.id).first()
|
# file = SithFile.objects.filter(id=self.id).first()
|
||||||
return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) or user.can_edit(file)
|
return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID)# or user.can_edit(file)
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
def can_be_viewed_by(self, user):
|
||||||
file = SithFile.objects.filter(id=self.id).first()
|
# file = SithFile.objects.filter(id=self.id).first()
|
||||||
return self.can_be_edited_by(user) or (self.is_in_sas and self.is_moderated and
|
return self.can_be_edited_by(user) or (self.is_in_sas and self.is_moderated and
|
||||||
user.was_subscribed()) or user.can_view(file)
|
user.was_subscribed())# or user.can_view(file)
|
||||||
|
|
||||||
def get_download_url(self):
|
def get_download_url(self):
|
||||||
return reverse('sas:download', kwargs={'picture_id': self.id})
|
return reverse('sas:download', kwargs={'picture_id': self.id})
|
||||||
@ -88,14 +88,22 @@ class Album(SithFile):
|
|||||||
class Meta:
|
class Meta:
|
||||||
proxy = True
|
proxy = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def children_pictures(self):
|
||||||
|
return Picture.objects.filter(parent=self, is_folder=False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def children_albums(self):
|
||||||
|
return Album.objects.filter(parent=self, is_folder=True)
|
||||||
|
|
||||||
def can_be_edited_by(self, user):
|
def can_be_edited_by(self, user):
|
||||||
file = SithFile.objects.filter(id=self.id).first()
|
# file = SithFile.objects.filter(id=self.id).first()
|
||||||
return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) or user.can_edit(file)
|
return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID)# or user.can_edit(file)
|
||||||
|
|
||||||
def can_be_viewed_by(self, user):
|
def can_be_viewed_by(self, user):
|
||||||
file = SithFile.objects.filter(id=self.id).first()
|
# file = SithFile.objects.filter(id=self.id).first()
|
||||||
return self.can_be_edited_by(user) or (self.is_in_sas and self.is_moderated and
|
return self.can_be_edited_by(user) or (self.is_in_sas and self.is_moderated and
|
||||||
user.was_subscribed()) or user.can_view(file)
|
user.was_subscribed())# or user.can_view(file)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('sas:album', kwargs={'album_id': self.id})
|
return reverse('sas:album', kwargs={'album_id': self.id})
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<a href="{{ url('sas:main') }}">SAS</a> > {{ print_path(album.parent) }} {{ album.get_display_name() }}
|
<a href="{{ url('sas:main') }}">SAS</a> > {{ print_path(album.parent) }} {{ album.get_display_name() }}
|
||||||
<h3>{{ album.get_display_name() }}</h3>
|
<h3>{{ album.get_display_name() }}</h3>
|
||||||
<a href="{{ url('sas:album_edit', album_id=album.id) }}">{% trans %}Edit{% endtrans %}</a><br>
|
<a href="{{ url('sas:album_edit', album_id=album.id) }}">{% trans %}Edit{% endtrans %}</a><br>
|
||||||
|
{{ timezone.now() }}
|
||||||
<hr>
|
<hr>
|
||||||
{% set edit_mode = user.can_edit(album) %}
|
{% set edit_mode = user.can_edit(album) %}
|
||||||
{% if edit_mode %}
|
{% if edit_mode %}
|
||||||
@ -38,19 +39,17 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div>
|
<div>
|
||||||
{% for a in album.children.filter(is_folder=True).order_by('-id') %}
|
{% for a in album.children_albums.order_by('-id') %}
|
||||||
<div style="display: inline-block;">
|
<div style="display: inline-block;">
|
||||||
{% if edit_mode %}
|
{% if edit_mode %}
|
||||||
<input type="checkbox" name="file_list" value="{{ a.id }}">
|
<input type="checkbox" name="file_list" value="{{ a.id }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.can_view(a.as_album) %}
|
{% if user.can_view(a) %}
|
||||||
<a href="{{ url("sas:album", album_id=a.id) }}" style="display: inline-block">
|
<a href="{{ url("sas:album", album_id=a.id) }}" style="display: inline-block">
|
||||||
<div class="album{% if not a.is_moderated %} not_moderated{% endif %}">
|
<div class="album{% if not a.is_moderated %} not_moderated{% endif %}">
|
||||||
<div>
|
<div>
|
||||||
{% if a.file %}
|
{% if a.file %}
|
||||||
<img src="{{ a.as_picture.get_download_url() }}" alt="{% trans %}preview{% endtrans %}">
|
<img src="{{ a.get_download_url() }}" alt="{% trans %}preview{% endtrans %}">
|
||||||
{% elif a.children.filter(is_folder=False, is_moderated=True).exists() %}
|
|
||||||
<img src="{{ a.children.filter(is_folder=False).first().as_picture.get_download_thumb_url() }}" alt="{% trans %}preview{% endtrans %}">
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<img src="{{ static('core/img/sas.jpg') }}" alt="{% trans %}preview{% endtrans %}">
|
<img src="{{ static('core/img/sas.jpg') }}" alt="{% trans %}preview{% endtrans %}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -63,15 +62,15 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{% for p in album.children.filter(is_folder=False).order_by('id') %}
|
{% for p in album.children_pictures.order_by('id') %}
|
||||||
<div style="display: inline-block;">
|
<div style="display: inline-block;">
|
||||||
{% if edit_mode %}
|
{% if edit_mode %}
|
||||||
<input type="checkbox" name="file_list" value="{{ p.id }}">
|
<input type="checkbox" name="file_list" value="{{ p.id }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.can_view(p.as_picture) %}
|
{% if user.can_view(p) %}
|
||||||
<div class="picture{% if not p.is_moderated %} not_moderated{% endif %}">
|
<div class="picture{% if not p.is_moderated %} not_moderated{% endif %}">
|
||||||
<a href="{{ url("sas:picture", picture_id=p.id) }}#pict">
|
<a href="{{ url("sas:picture", picture_id=p.id) }}#pict">
|
||||||
<img src="{{ p.as_picture.get_download_thumb_url() }}" alt="{{ p.get_display_name() }}" />
|
<img src="{{ p.get_download_thumb_url() }}" alt="{{ p.get_display_name() }}" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -86,6 +85,7 @@
|
|||||||
{{ form.as_p() }}
|
{{ form.as_p() }}
|
||||||
<p><input type="submit" value="{% trans %}Upload{% endtrans %}" /></p>
|
<p><input type="submit" value="{% trans %}Upload{% endtrans %}" /></p>
|
||||||
</form>
|
</form>
|
||||||
|
{{ timezone.now() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block script %}
|
{% block script %}
|
||||||
|
Loading…
Reference in New Issue
Block a user