Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ MAINTAINER Computer Science House <rtp@csh.rit.edu>
ENV IMAGEIO_USERDIR /var/lib/gallery

RUN apt-get update && \
apt-get install -y libldap-dev libsasl2-dev libmagic-dev && \
apt-get install -y libldap-dev libsasl2-dev libmagic-dev ghostscript && \
apt-get autoremove --yes && \
apt-get clean autoclean && \
rm -rf /var/lib/{apt,dpkg,cache,log}/ && \
mkdir -p /opt/gallery /var/lib/gallery

RUN pip install --upgrade pip

WORKDIR /opt/gallery
ADD . /opt/gallery

Expand Down
3 changes: 1 addition & 2 deletions gallery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,6 @@ def render_dir(dir_id: int, auth_dict: Optional[Dict[str, Any]] = None):
description = dir_model.description
display_description = len(description) > 0


display_parent = True
if dir_model is None or dir_model.parent is None or dir_id == ROOT_DIR_ID:
display_parent = False
Expand Down Expand Up @@ -960,7 +959,7 @@ def render_file(file_id: int, auth_dict: Optional[Dict[str, Any]] = None):
file_model = File.query.filter(File.id == file_id).first()
if file_model is None:
abort(404)
if file_model.hidden and (not auth_dict['is_eboard'] and not auth_dict['is_rtp']):
if file_model.hidden and (not auth_dict['is_eboard'] and not auth_dict['is_rtp'] and not auth_dict['is_alumni']):
abort(404)
gallery_lockdown = util.get_lockdown_status()
if gallery_lockdown and (not auth_dict['is_eboard'] and not auth_dict['is_rtp']):
Expand Down
2 changes: 1 addition & 1 deletion gallery/_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os import environ as env

__version__ = "2.1.1"
__version__ = "2.1.2"

BUILD_REFERENCE = env.get("OPENSHIFT_BUILD_REFERENCE")
COMMIT_HASH = env.get("OPENSHIFT_BUILD_COMMIT")
Expand Down
19 changes: 19 additions & 0 deletions gallery/file_modules/pdf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import os
from wand.image import Image
from wand.color import Color

from gallery.file_modules import FileModule
from gallery.util import hash_file


class PDFFile(FileModule):
Expand All @@ -8,3 +13,17 @@ def __init__(self, file_path, dir_path):
self.mime_type = "application/pdf"

self.generate_thumbnail()

def generate_thumbnail(self):
self.thumbnail_uuid = hash_file(self.file_path) + ".jpg"

with Image(filename=self.file_path, resolution=300) as all_pages:
with Image(all_pages.sequence[0]) as first_page:
with Image(width=first_page.width, height=first_page.height,
background=Color("#EEEEEE")) as bg:
bg.composite(first_page, 0, 0)
size = first_page.width if first_page.width < first_page.height else first_page.height
bg.crop(width=size, height=size, gravity='north') # top of first page
bg.resize(256, 256)
bg.format = 'jpeg'
bg.save(filename=os.path.join(self.dir_path, self.thumbnail_uuid))
3 changes: 3 additions & 0 deletions gallery/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def is_rtp(self, uid: str) -> bool:
rtp_group = self._ldap.get_group('rtp')
return rtp_group.check_member(self._ldap.get_member(uid, uid=True))

def is_alumni(self, uid: str) -> bool:
return not is_member_of_group(self._ldap.get_member(uid, uid=True), 'current_student')

def get_members(self) -> List[Dict[str, str]]:
if self._ldap is None:
return []
Expand Down
2 changes: 1 addition & 1 deletion gallery/templates/view_dir.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{% if children|length >= 1 %}
<div class="row" id="child_list">
{% for child_type, child in children %}
{% if not child.hidden or (auth_dict['is_eboard'] or auth_dict['is_rtp']) %}
{% if not child.hidden or (auth_dict['is_eboard'] or auth_dict['is_rtp']) or auth_dict['is_alumni'] %}
<div class="col-md-3 col-sm-4 col-xs-6">
<div class="panel panel-default">
<div class="panel-body">
Expand Down
2 changes: 2 additions & 0 deletions gallery/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def wrapped_function(*args: Any, **kwargs: Any) -> Any:
name = ldap.convert_uuid_to_displayname(uuid)
is_eboard = ldap.is_eboard(uid)
is_rtp = ldap.is_rtp(uid)
is_alumni = ldap.is_alumni(uid)

# NOTE(rossdylan): This is probably a more precise type than we need,
# if different data is needed just expand the value type to Any
Expand All @@ -83,6 +84,7 @@ def wrapped_function(*args: Any, **kwargs: Any) -> Any:
auth_dict['name'] = name
auth_dict['is_eboard'] = is_eboard
auth_dict['is_rtp'] = is_rtp
auth_dict['is_alumni'] = is_alumni
kwargs['auth_dict'] = auth_dict
return func(*args, **kwargs)
return wrapped_function
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ gunicorn==19.9.0
moviepy==0.2.3.5
imageio==2.4.0
boto3
werkzeug == 0.16.1
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ summary = Python Photo Gallery Written in Flask
url = "https://github.com/ComputerScienceHouse/gallery"
description-file = README.md
license = MIT
version = 2.1.1
version = 2.1.2
classifier =
Natural Language :: English
Operating System :: POSIX :: Linux