photos package

Submodules

photos.admin module

class photos.admin.AlbumAdmin(model, admin_site)[source]

Bases: utils.translation.TranslatedModelAdmin

Model for Album admin page.

date_hierarchy = 'date'
exclude = None
fields = ('title_en', 'slug', 'date', 'hidden', 'shareable', 'album_archive', '_cover')
form

alias of photos.forms.AlbumForm

get_queryset(request)[source]

Get Albums and add the amount of photos as an annotation.

list_display = ('title', 'date', 'num_photos', 'hidden', 'shareable')
list_filter = ('hidden', 'shareable')
property media
num_photos(obj)[source]

Pretty-print the number of photos.

prepopulated_fields = {'slug': ('date', 'title_en')}
save_model(request, obj, form, change)[source]

Save the new Album by extracting the archive.

search_fields = ('title_en', 'date')
class photos.admin.PhotoAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Model for Photo admin page.

exclude = ('_digest',)
list_display = ('__str__', 'album', 'hidden')
list_filter = ('album', 'hidden')
property media
save_model(request, obj, form, change)[source]

Save new Photo.

search_fields = ('file',)

photos.apps module

class photos.apps.PhotosConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

AppConfig class for Photos app.

name = 'photos'
ready()[source]

Import the signals when the app is ready.

verbose_name = 'Photos'

photos.forms module

class photos.forms.AlbumForm(*args, **kwargs)[source]

Bases: django.forms.models.ModelForm

Class for an album submission form.

class Meta[source]

Bases: object

Meta class for AlbumForm.

fields = ('title_en', 'date', 'slug', 'hidden', 'new_album_notification', 'shareable', '_cover')
model

alias of photos.models.Album

base_fields = {'_cover': <django.forms.models.ModelChoiceField object>, 'album_archive': <django.forms.fields.FileField object>, 'date': <django.forms.fields.DateField object>, 'hidden': <django.forms.fields.BooleanField object>, 'new_album_notification': <django.forms.models.ModelChoiceField object>, 'shareable': <django.forms.fields.BooleanField object>, 'slug': <django.forms.fields.SlugField object>, 'title_en': <django.forms.fields.CharField object>}
declared_fields = {'album_archive': <django.forms.fields.FileField object>}
property media

Return all media required to render the widgets on this form.

photos.models module

class photos.models.Album(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Model for Album objects.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

property access_token

Return access token for album.

cover

Return cover of Album.

If a cover is not set, return a random photo or None if there are no photos.

date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

dirname

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_absolute_url()[source]

Get url of Album.

get_next_by_date(*, field=<django.db.models.fields.DateField: date>, is_next=True, **kwargs)
get_previous_by_date(*, field=<django.db.models.fields.DateField: date>, is_next=False, **kwargs)
hidden

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

new_album_notification

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

new_album_notification_id
objects = <django.db.models.manager.Manager object>
photo_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

photosdir = 'photos'
photospath = '/__w/concrexit/concrexit/website/media/photos'
save(**kwargs)[source]

Save album and send appropriate notifications.

shareable

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

slug

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property title

Accessor that fetches the localized variant of title

title_en

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class photos.models.Photo(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Model for a Photo object.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

album

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

album_id
covered_album

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

file

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

get_rotation_display(*, field=<django.db.models.fields.IntegerField: rotation>)
hidden

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
rotation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

photos.models.photo_uploadto(instance, filename)[source]

Get path of file to upload to.

photos.services module

photos.services.check_shared_album_token(album, token)[source]

Return a 404 if the token does not match the album token.

photos.services.extract_archive(request, album, archive)[source]

Extract zip and tar files.

photos.services.extract_photo(request, archive_file, photo, album)[source]

Extract ZipInfo or TarInfo Photo object.

photos.services.get_annotated_accessible_albums(request, albums)[source]

Annotate the albums which are accessible by the user.

photos.services.is_album_accessible(request, album)[source]

Check if the request user can access an album.

photos.services.photo_determine_rotation(pil_image)[source]

Get the rotation of an image.

photos.services.save_photo(photo_obj)[source]

Convert a Photo object to a JPG image and save it.

Returns True if photo is saved successfully and False if Photo is a duplicate.

photos.signals module

photos.signals.pre_photo_delete(sender, instance, **kwargs)[source]

Remove main photo file on deletion.

photos.urls module

photos.validators module

class photos.validators.ArchiveFileTypeValidator(*args, **kwargs)[source]

Bases: object

Validator class for archive files.

deconstruct()

Return a 3-tuple of class import path, positional arguments, and keyword arguments.

message = 'Only zip and tar files are allowed.'
types = ['application/gzip', 'application/zip', 'application/x-gzip']

photos.views module

photos.views.detail(request, slug)[source]

Render an album, if it accessible by the user.

photos.views.download(request, slug, filename)[source]

Download a photo if the album of the photo is accessible by the user.

photos.views.index(request)[source]

Render the index page showing multiple album cards.

photos.views.shared_album(request, slug, token)[source]

Render a shared album if the correct token is provided.

photos.views.shared_download(request, slug, token, filename)[source]

Download a photo from a shared album if the album token is provided.