Events und Gallery in einzelne Apps aufgetielt.
Lokalisierung auf einzelne Apps aufgeteilt Mai-Star Ranking in die Navigation integriert
This commit is contained in:
@@ -5,10 +5,11 @@ Created on 19.09.2011
|
||||
"""
|
||||
# import stuff we need from django
|
||||
from django.contrib import admin
|
||||
from events.models import Event, Photo, Location
|
||||
from imagekit.admin import AdminThumbnail
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from events.models import Event, Photo, Location
|
||||
|
||||
|
||||
class EventInline(admin.TabularInline):
|
||||
model = Event
|
||||
|
||||
@@ -6,6 +6,7 @@ Created on 30.09.2011
|
||||
"""
|
||||
from . import models
|
||||
|
||||
|
||||
def upcoming_events(request):
|
||||
return {
|
||||
'current_event': models.Event.objects.current_event(),
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
from django.conf.urls import patterns, include, url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', views.UpcomingEvents.as_view(), name='upcoming-events'),
|
||||
url(
|
||||
r'^(?P<year>[\d]{4})/$',
|
||||
views.EventArchiveYear.as_view(),
|
||||
name='event-archive'
|
||||
),
|
||||
url(
|
||||
r'^(?P<year>[\d]{4})/(?P<month>[\d]+)/$',
|
||||
views.EventArchiveMonth.as_view(),
|
||||
name='event-archive'
|
||||
),
|
||||
url(
|
||||
r'^(?P<year>[\d]{4})/(?P<month>[\d]+)/(?P<pk>[\d]+)/$',
|
||||
views.EventDetail.as_view(),
|
||||
name='event-detail'
|
||||
),
|
||||
url(
|
||||
r'^(?P<year>[\d]{4})/(?P<month>[\d]+)/(?P<pk>[\d]+)/edit/$',
|
||||
views.EventForm.as_view(),
|
||||
name='event-form'
|
||||
),
|
||||
url(
|
||||
r'^add/$',
|
||||
views.EventForm.as_view(),
|
||||
name='event-form'
|
||||
),
|
||||
url(
|
||||
r'^archive/$',
|
||||
views.EventArchiveIndex.as_view(),
|
||||
name='event-archive'
|
||||
),
|
||||
)
|
||||
@@ -3,20 +3,22 @@ Created on 03.10.2011
|
||||
|
||||
@author: christian
|
||||
"""
|
||||
from . import models
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from . import models
|
||||
from utils.html5.widgets import DateTimeInput
|
||||
|
||||
|
||||
user_query = get_user_model().objects.all()
|
||||
|
||||
|
||||
class PhotoUploadForm(forms.Form):
|
||||
error_css_class = 'error'
|
||||
required_css_class = 'required'
|
||||
photographer = forms.ModelChoiceField(user_query, required=True,)
|
||||
event = forms.ModelChoiceField(models.Event.objects.all(), required=True,)
|
||||
photographer = forms.ModelChoiceField(user_query, required=True, )
|
||||
event = forms.ModelChoiceField(models.Event.objects.all(), required=True, )
|
||||
upload = forms.FileField(
|
||||
label=_('Images'),
|
||||
required=True,
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
from django.conf.urls import patterns, include, url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', views.EventGallery.as_view(), name='event-gallery'),
|
||||
url(
|
||||
r'^(?P<event>[\d]+)/$',
|
||||
views.EventPhotoList.as_view(),
|
||||
name='event-photo-list'
|
||||
),
|
||||
url(
|
||||
r'^(?P<event>[\d]+)/(?P<pk>[\d]+)/$',
|
||||
views.EventPhoto.as_view(),
|
||||
name='event-photo'
|
||||
),
|
||||
url(
|
||||
r'^(?P<event>[\d]+)/upload/$',
|
||||
views.EventPhotoUpload.as_view(),
|
||||
name='event-photo-upload'
|
||||
),
|
||||
url(
|
||||
r'^delete/(?P<pk>[\d]+)/$',
|
||||
views.DeleteEventPhoto.as_view(),
|
||||
name='delete-event-photo'
|
||||
),
|
||||
url(
|
||||
r'^upload/$',
|
||||
views.EventPhotoUpload.as_view(),
|
||||
name='event-photo-upload'
|
||||
),
|
||||
)
|
||||
BIN
events/locale/de/LC_MESSAGES/django.mo
Normal file
BIN
events/locale/de/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
300
events/locale/de/LC_MESSAGES/django.po
Normal file
300
events/locale/de/LC_MESSAGES/django.po
Normal file
@@ -0,0 +1,300 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: kasu.events\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-12-09 20:35+0100\n"
|
||||
"PO-Revision-Date: 2014-12-08 16:06+0100\n"
|
||||
"Last-Translator: Christian Berg <xeniac.at@gmail.com>\n"
|
||||
"Language-Team: Kasu <verein@kasu.at>\n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Translated-Using: django-rosetta 0.7.2\n"
|
||||
"X-Generator: Poedit 1.6.11\n"
|
||||
|
||||
#: admin.py:17 models.py:81
|
||||
msgid "Event Series"
|
||||
msgstr "Veranstaltungsreihen"
|
||||
|
||||
#: forms.py:23
|
||||
msgid "Images"
|
||||
msgstr "Bilder"
|
||||
|
||||
#: forms.py:50
|
||||
msgid "start"
|
||||
msgstr "Beginn"
|
||||
|
||||
#: forms.py:54
|
||||
msgid "end"
|
||||
msgstr "Ende"
|
||||
|
||||
#: models.py:67 models.py:155
|
||||
msgid "Name"
|
||||
msgstr "Name"
|
||||
|
||||
#: models.py:68 models.py:156
|
||||
msgid "Description"
|
||||
msgstr "Beschreibung"
|
||||
|
||||
#: models.py:70 templates/events/event_archive.html:41
|
||||
#: templates/events/event_detail.html:31 templates/events/event_detail.html:77
|
||||
#: templates/events/event_list.html:15
|
||||
msgid "Start"
|
||||
msgstr "Beginn"
|
||||
|
||||
#: models.py:71 templates/events/event_detail.html:32
|
||||
#: templates/events/event_detail.html:78
|
||||
msgid "End"
|
||||
msgstr "Ende"
|
||||
|
||||
#: models.py:72 models.py:159 templates/events/event_detail.html:37
|
||||
#: templates/events/event_detail.html:73 templates/events/event_detail.html:79
|
||||
msgid "Homepage"
|
||||
msgstr "Homepage"
|
||||
|
||||
#: models.py:73 models.py:157
|
||||
msgid "Image"
|
||||
msgstr "Bild"
|
||||
|
||||
#: models.py:75
|
||||
msgid "Tournament"
|
||||
msgstr "Turnier"
|
||||
|
||||
#: models.py:76
|
||||
msgid ""
|
||||
"This event is a tournament, different rules apply for the kyu "
|
||||
"ranking."
|
||||
msgstr ""
|
||||
"Diese Veranstaltung ist ein Turnier, es gelten andere Regeln für das Kyu "
|
||||
"Ranking."
|
||||
|
||||
#: models.py:82
|
||||
msgid ""
|
||||
"Wenn dieser Event zu einer Veranstaltungsreihe gehört werden Ort, "
|
||||
"Beschreibung, Bild und Homepage von dem hier angegebenen Event "
|
||||
"übernommen."
|
||||
msgstr ""
|
||||
"Wenn dieser Termin zu einer Veranstaltungsreihe gehört werden Ort, "
|
||||
"Beschreibung, Bild und Homepage von dem hier angegebenen Event übernommen."
|
||||
|
||||
#: models.py:88
|
||||
msgid "Event"
|
||||
msgstr "Termin"
|
||||
|
||||
#: models.py:89
|
||||
msgid "Events"
|
||||
msgstr "Termine"
|
||||
|
||||
#: models.py:160
|
||||
msgid "Postal Code"
|
||||
msgstr "Postleitzahl"
|
||||
|
||||
#: models.py:161
|
||||
msgid "Street Address"
|
||||
msgstr "Straße"
|
||||
|
||||
#: models.py:162
|
||||
msgid "Locality"
|
||||
msgstr "Ort"
|
||||
|
||||
#: models.py:163
|
||||
msgid "Country"
|
||||
msgstr "Land"
|
||||
|
||||
#: models.py:166
|
||||
msgid "Venue"
|
||||
msgstr "Veranstaltungsort"
|
||||
|
||||
#: models.py:167
|
||||
msgid "Venues"
|
||||
msgstr "Veranstaltungsorte"
|
||||
|
||||
#: views.py:193
|
||||
msgid "Event does not exist"
|
||||
msgstr "Veranstaltung gibt es nicht"
|
||||
|
||||
#: templates/events/event_archive.html:5 templates/events/event_archive.html:9
|
||||
msgid "Event Archive"
|
||||
msgstr "Veranstaltungsarchiv"
|
||||
|
||||
#: templates/events/event_archive.html:36 templates/events/event_list.html:11
|
||||
msgid "Event Image"
|
||||
msgstr "Veranstaltungsbild"
|
||||
|
||||
#: templates/events/event_archive.html:44 templates/events/event_list.html:18
|
||||
msgid "from"
|
||||
msgstr "von"
|
||||
|
||||
#: templates/events/event_archive.html:44 templates/events/event_list.html:18
|
||||
msgid "to"
|
||||
msgstr "bis"
|
||||
|
||||
#: templates/events/event_archive.html:52
|
||||
#: templates/events/event_detail.html:35 templates/events/event_detail.html:65
|
||||
#: templates/events/event_list.html:26
|
||||
msgid "Location"
|
||||
msgstr "Ort"
|
||||
|
||||
#: templates/events/event_archive.html:56
|
||||
#: templates/events/event_archive.html:57 templates/events/event_list.html:30
|
||||
msgid "Comments"
|
||||
msgstr "Kommentare"
|
||||
|
||||
#: templates/events/event_archive.html:60
|
||||
#: templates/events/event_archive.html:61
|
||||
#: templates/events/event_detail.html:39 templates/events/event_detail.html:49
|
||||
msgid "Photos"
|
||||
msgstr "Fotos"
|
||||
|
||||
#: templates/events/event_archive.html:64
|
||||
#: templates/events/event_archive.html:65
|
||||
#: templates/events/event_archive.html:66
|
||||
#: templates/events/event_detail.html:38 templates/events/event_detail.html:48
|
||||
#: templates/events/event_detail.html:50
|
||||
msgid "Hanchans"
|
||||
msgstr "Hanchans"
|
||||
|
||||
#: templates/events/event_archive.html:70
|
||||
msgid " Edit"
|
||||
msgstr "Bearbeiten"
|
||||
|
||||
#: templates/events/event_detail.html:40
|
||||
msgid "tourney"
|
||||
msgstr "Turnier"
|
||||
|
||||
#: templates/events/event_detail.html:40
|
||||
msgid "other rules apply here"
|
||||
msgstr "hier gelten andere Regeln"
|
||||
|
||||
#: templates/events/event_detail.html:48
|
||||
msgid "Info"
|
||||
msgstr "Info"
|
||||
|
||||
#: templates/events/event_detail.html:51
|
||||
msgid "Mai-Star Games"
|
||||
msgstr "Mai-Star Spiele"
|
||||
|
||||
#: templates/events/event_detail.html:54
|
||||
msgid "Tournament Ranking"
|
||||
msgstr "Turnier Wertung"
|
||||
|
||||
#: templates/events/event_detail.html:75
|
||||
msgid "Date"
|
||||
msgstr "Datum"
|
||||
|
||||
#: templates/events/event_detail.html:91
|
||||
msgid "Share on Google+"
|
||||
msgstr "Auf Google+ teilen"
|
||||
|
||||
#: templates/events/event_detail.html:92
|
||||
msgid "Share on Twitter"
|
||||
msgstr "Auf Twitter teilen"
|
||||
|
||||
#: templates/events/event_detail.html:93
|
||||
msgid "Share on Facebook"
|
||||
msgstr "Auf Facebook teilen"
|
||||
|
||||
#: templates/events/event_detail.html:94
|
||||
msgid "Show on Google Maps"
|
||||
msgstr "Auf Google Maps zeigen"
|
||||
|
||||
#: templates/events/event_detail.html:110 templates/events/event_form.html:13
|
||||
msgid "Edit Event"
|
||||
msgstr "Termin bearbeiten"
|
||||
|
||||
#: templates/events/event_form.html:13 templates/events/page.html:15
|
||||
msgid "Add Event"
|
||||
msgstr "Neuer Termin"
|
||||
|
||||
#: templates/events/event_form.html:23
|
||||
msgid "reset"
|
||||
msgstr "Zurücksetzen"
|
||||
|
||||
#: templates/events/event_form.html:24
|
||||
msgid "save"
|
||||
msgstr "Speichern"
|
||||
|
||||
#: templates/events/event_list.html:4 templates/events/event_list.html.py:5
|
||||
msgid "Upcoming Events"
|
||||
msgstr "Bevorstehende Veranstaltungen"
|
||||
|
||||
#: templates/events/event_list.html:41
|
||||
msgid " Upload"
|
||||
msgstr "Hochladen"
|
||||
|
||||
#: templates/events/page.html:10
|
||||
msgid "Add to Google Calendar"
|
||||
msgstr "Zu Google Kalender hinzufügen"
|
||||
|
||||
#~ msgid "left"
|
||||
#~ msgstr "Links"
|
||||
|
||||
#~ msgid "center"
|
||||
#~ msgstr "Mitte"
|
||||
|
||||
#~ msgid "right"
|
||||
#~ msgstr "Rechts"
|
||||
|
||||
#~ msgid "top"
|
||||
#~ msgstr "Oben"
|
||||
|
||||
#~ msgid "middle"
|
||||
#~ msgstr "Mitte"
|
||||
|
||||
#~ msgid "bottom"
|
||||
#~ msgstr "Unten"
|
||||
|
||||
#~ msgid "horizontal Anchorpoint"
|
||||
#~ msgstr "horizontaler Anker"
|
||||
|
||||
#~ msgid "vertical Anchorpoint"
|
||||
#~ msgstr "vertikaler Anker"
|
||||
|
||||
#~ msgid "Startpage"
|
||||
#~ msgstr "Startseite"
|
||||
|
||||
#~ msgid "Display this Photo on the Startpage Teaser"
|
||||
#~ msgstr "Foto als Teaser auf der Startseite verwenden."
|
||||
|
||||
#~ msgid "Published on"
|
||||
#~ msgstr "Veröffentlicht am"
|
||||
|
||||
#~ msgid "Number of views"
|
||||
#~ msgstr "Wie oft gesehen"
|
||||
|
||||
#~ msgid "Event Images"
|
||||
#~ msgstr "Veranstaltungsbilder"
|
||||
|
||||
#~ msgid "Cancel"
|
||||
#~ msgstr "Abbrechen"
|
||||
|
||||
#~ msgid "Delete"
|
||||
#~ msgstr "Löschen"
|
||||
|
||||
#~ msgid "previous"
|
||||
#~ msgstr "Zurück"
|
||||
|
||||
#~ msgid "download"
|
||||
#~ msgstr "Herunterladen"
|
||||
|
||||
#~ msgid "Photographer"
|
||||
#~ msgstr "Fotograf"
|
||||
|
||||
#~ msgid "on"
|
||||
#~ msgstr "am"
|
||||
|
||||
#~ msgid "Upload"
|
||||
#~ msgstr "Hochladen"
|
||||
|
||||
#~ msgid "delete"
|
||||
#~ msgstr "Löschen"
|
||||
|
||||
#~ msgid "upload"
|
||||
#~ msgstr "hochladen"
|
||||
240
events/models.py
240
events/models.py
@@ -1,33 +1,14 @@
|
||||
# -'- Encoding: utf-8 -*-
|
||||
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import ugettext as _
|
||||
from imagekit import ImageSpec
|
||||
import imagekit
|
||||
from imagekit.models import ImageSpecField
|
||||
from pilkit import processors
|
||||
import pyexiv2
|
||||
|
||||
from utils import COUNTRIES, OverwriteStorage
|
||||
|
||||
|
||||
CHOICES_HORIZONTAL = (
|
||||
(0.00000001, _('left')),
|
||||
(0.5, _('center')),
|
||||
(1, _('right'))
|
||||
)
|
||||
|
||||
CHOICES_VERTICAL = (
|
||||
(0.00000001, _('top')),
|
||||
(0.5, _('middle')),
|
||||
(1, _('bottom'))
|
||||
)
|
||||
from gallery.models import Photo
|
||||
from kasu import image_models
|
||||
|
||||
|
||||
def get_upload_path(instance, filename):
|
||||
@@ -56,79 +37,6 @@ def get_upload_path(instance, filename):
|
||||
return "events/%s/%s" % (instance.event.id, filename)
|
||||
|
||||
|
||||
def post_save_image(sender, instance=None, created=False, raw=False, **kwargs):
|
||||
"""
|
||||
Reganerate the images.
|
||||
"""
|
||||
os.remove(instance.display.path)
|
||||
os.remove(instance.callout.path)
|
||||
os.remove(instance.thumbnail.path)
|
||||
|
||||
"""
|
||||
instance.callout.generate(force=True)
|
||||
instance.display.generate(force=True)
|
||||
instance.thumbnail.generate(force=True)
|
||||
"""
|
||||
|
||||
|
||||
class CalloutImage(ImageSpec):
|
||||
format = 'PNG'
|
||||
width = 620
|
||||
height = 300
|
||||
|
||||
@property
|
||||
def processors(self):
|
||||
model, field_name = imagekit.utils.get_field_info(self.source) # @UnusedVariable @IgnorePep8
|
||||
anchor = model.get_anchor()
|
||||
if anchor:
|
||||
return [processors.Transpose(), processors.ResizeToFill(
|
||||
width=self.width,
|
||||
height=self.height, anchor=anchor
|
||||
)]
|
||||
else:
|
||||
return [processors.Transpose(), processors.SmartResize(
|
||||
width=self.width,
|
||||
height=self.height
|
||||
)]
|
||||
|
||||
|
||||
class DisplayImage(ImageSpec):
|
||||
format = 'PNG'
|
||||
processors = [processors.Transpose(),
|
||||
processors.ResizeToFit(width=940, height=940, upscale=False)]
|
||||
|
||||
|
||||
class ThumbnailImage(CalloutImage):
|
||||
format = 'PNG'
|
||||
width = 140
|
||||
height = 140
|
||||
|
||||
|
||||
imagekit.register.generator('kasu:image:callout', CalloutImage)
|
||||
imagekit.register.generator('kasu:image:display', DisplayImage)
|
||||
imagekit.register.generator('kasu:image:thumbnail', ThumbnailImage)
|
||||
|
||||
|
||||
class ImageModel(models.Model):
|
||||
callout = ImageSpecField(source='image', id='kasu:image:callout')
|
||||
display = ImageSpecField(source='image', id='kasu:image:display')
|
||||
thumbnail = ImageSpecField(source='image', id='kasu:image:thumbnail')
|
||||
|
||||
def get_anchor(self):
|
||||
try:
|
||||
anchor_horizontal = getattr(self, 'anchor_horizontal')
|
||||
anchor_vertical = getattr(self, 'anchor_vertical')
|
||||
except AttributeError:
|
||||
return None
|
||||
if anchor_horizontal and anchor_vertical:
|
||||
return self.anchor_horizontal, self.anchor_vertical
|
||||
else:
|
||||
return None
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class EventManager(models.Manager):
|
||||
def current_event(self):
|
||||
try:
|
||||
@@ -155,7 +63,7 @@ class EventManager(models.Manager):
|
||||
return result
|
||||
|
||||
|
||||
class Event(ImageModel):
|
||||
class Event(image_models.ImageModel):
|
||||
name = models.CharField(_('Name'), max_length=255)
|
||||
description = models.TextField(_("Description"), blank=True)
|
||||
location = models.ForeignKey('Location')
|
||||
@@ -232,7 +140,7 @@ class Event(ImageModel):
|
||||
self.url = master_event.url
|
||||
self.image = master_event.image
|
||||
self.photo_count = self.photo_set.count()
|
||||
models.Model.save(self, **kwargs)
|
||||
super(Event, self).save(**kwargs)
|
||||
|
||||
# Update the rest of the event series:
|
||||
for sub_event in Event.objects.filter(event_series=self):
|
||||
@@ -243,7 +151,7 @@ class Event(ImageModel):
|
||||
hanchan.save()
|
||||
|
||||
|
||||
class Location(ImageModel):
|
||||
class Location(image_models.ImageModel):
|
||||
name = models.CharField(_("Name"), max_length=200)
|
||||
description = models.TextField(_("Description"), blank=True)
|
||||
image = models.ImageField(_("Image"), upload_to=get_upload_path,
|
||||
@@ -267,137 +175,7 @@ class Location(ImageModel):
|
||||
return ','.join(address)
|
||||
|
||||
|
||||
class PhotoManager(models.Manager):
|
||||
def get_random(self, startpage=True):
|
||||
if startpage:
|
||||
queryset = self.filter(on_startpage=True)
|
||||
else:
|
||||
queryset = self.all().order_by('?')[0]
|
||||
try:
|
||||
return queryset.order_by('?')[0]
|
||||
except IndexError:
|
||||
return Photo()
|
||||
|
||||
|
||||
class Photo(ImageModel):
|
||||
name = models.CharField(_("Name"), max_length=100, blank=True)
|
||||
image = models.ImageField(_("Image"), upload_to=get_upload_path,
|
||||
storage=OverwriteStorage())
|
||||
anchor_horizontal = models.FloatField(
|
||||
_('horizontal Anchorpoint'),
|
||||
choices=CHOICES_HORIZONTAL,
|
||||
blank=True, null=True,
|
||||
help_text='Der Ankerpunkt ist der interessante Teil des Bildes,\
|
||||
welcher nie abgeschnitten werden darf'
|
||||
)
|
||||
anchor_vertical = models.FloatField(
|
||||
_('vertical Anchorpoint'),
|
||||
choices=CHOICES_VERTICAL,
|
||||
blank=True, null=True,
|
||||
help_text='Wenn kein Ankerpunkt von Hand (horizontal und vertikal)\
|
||||
festgelegt wird, versucht die Software diesen selbst zu erraten.'
|
||||
)
|
||||
|
||||
event = models.ForeignKey(Event)
|
||||
description = models.TextField(
|
||||
_("Description"),
|
||||
max_length=300,
|
||||
blank=True
|
||||
)
|
||||
photographer = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
on_startpage = models.BooleanField(
|
||||
_("Startpage"),
|
||||
default=False,
|
||||
help_text=_('Display this Photo on the Startpage Teaser')
|
||||
)
|
||||
created_date = models.DateTimeField(_("Published on"))
|
||||
views = models.PositiveIntegerField(
|
||||
_("Number of views"),
|
||||
editable=False,
|
||||
default=0
|
||||
)
|
||||
objects = PhotoManager()
|
||||
metadata = None
|
||||
orientation = 1
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Event Image')
|
||||
verbose_name_plural = _('Event Images')
|
||||
ordering = ["created_date"]
|
||||
get_latest_by = "created_date"
|
||||
|
||||
def __unicode__(self):
|
||||
return os.path.basename(self.image.name)
|
||||
|
||||
def read_metadata(self):
|
||||
image_path = os.path.join(settings.MEDIA_ROOT, self.image.name)
|
||||
self.metadata = pyexiv2.ImageMetadata(image_path)
|
||||
self.metadata.read()
|
||||
try:
|
||||
self.orientation = self.metadata['Exif.Image.Orientation'].value
|
||||
except:
|
||||
self.orientation = 1
|
||||
|
||||
def save_metadata(self):
|
||||
if not self.metadata:
|
||||
self.read_metadata()
|
||||
self.metadata['Exif.Image.DateTime'] = self.created_date
|
||||
self.metadata['Exif.Image.ImageDescription'] = self.description
|
||||
self.metadata['Exif.Image.Artist'] = self.photographer.username
|
||||
self.metadata['Exif.Image.Orientation'] = self.orientation or 1
|
||||
self.metadata.write()
|
||||
|
||||
def rotate(self, rotate):
|
||||
"""
|
||||
Sets an the Exif tag in an image to set the right direction.
|
||||
This provides lossless image rotation.
|
||||
@param rotate: 'clockwise' or 'counter-clockwise' the direction in
|
||||
which we should rotate the image in 90° steps.
|
||||
"""
|
||||
if not self.metadata:
|
||||
self.read_metadata()
|
||||
if rotate == 'clockwise':
|
||||
if self.orientation == 1:
|
||||
self.orientation = 6
|
||||
elif self.orientation == 6:
|
||||
self.orientation = 3
|
||||
elif self.orientation == 3:
|
||||
self.orientation = 8
|
||||
else:
|
||||
self.orientation = 1
|
||||
elif rotate == 'counter-clockwise':
|
||||
if self.orientation == 1:
|
||||
self.orientation = 8
|
||||
elif self.orientation == 8:
|
||||
self.orientation = 3
|
||||
elif self.orientation == 3:
|
||||
self.orientation = 6
|
||||
else:
|
||||
self.orientation = 1
|
||||
self.save()
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse(
|
||||
'event-photo',
|
||||
kwargs={'event': self.event.id, 'pk': self.id}
|
||||
)
|
||||
|
||||
@property
|
||||
def next_photo(self):
|
||||
return self.get_next_by_created_date(event=self.event)
|
||||
|
||||
@property
|
||||
def previous_photo(self):
|
||||
return self.get_previous_by_created_date(event=self.event)
|
||||
|
||||
def save(self, **kwargs):
|
||||
"""
|
||||
Triggers to save related Event to save. This should force an update for
|
||||
the denormalized Photo count.
|
||||
"""
|
||||
ImageModel.save(self, **kwargs)
|
||||
self.save_metadata()
|
||||
self.event.save()
|
||||
|
||||
|
||||
models.signals.post_save.connect(post_save_image, sender=Photo)
|
||||
models.signals.post_save.connect(image_models.regenerate_image_cache,
|
||||
sender=Event)
|
||||
models.signals.post_save.connect(image_models.regenerate_image_cache,
|
||||
sender=Location)
|
||||
@@ -1,48 +0,0 @@
|
||||
from imagekit.specs import ImageSpec
|
||||
from imagekit import processors
|
||||
|
||||
|
||||
class ResizeDisplay(processors.Resize):
|
||||
width = 780
|
||||
crop = False
|
||||
upscale = False
|
||||
|
||||
|
||||
# first we define our thumbnail resize processor
|
||||
class ResizeCallout(processors.Resize):
|
||||
width = 620
|
||||
height = 300
|
||||
crop = True
|
||||
|
||||
|
||||
class ResizeAdmin(processors.Resize):
|
||||
width = 60
|
||||
height = 60
|
||||
crop = True
|
||||
|
||||
|
||||
class ResizeThumbnail(processors.Resize):
|
||||
width = 140
|
||||
height = 140
|
||||
crop = True
|
||||
|
||||
|
||||
# Different Image Sizes
|
||||
class Admin(ImageSpec):
|
||||
pre_cache = False
|
||||
processors = [processors.Transpose, ResizeAdmin]
|
||||
|
||||
|
||||
class Display(ImageSpec):
|
||||
pre_cache = False
|
||||
processors = [processors.Transpose, ResizeDisplay]
|
||||
|
||||
|
||||
class Callout(ImageSpec):
|
||||
pre_cache = False
|
||||
processors = [processors.Transpose, ResizeCallout]
|
||||
|
||||
|
||||
class Thumbnail(ImageSpec):
|
||||
pre_cache = False
|
||||
processors = [processors.Transpose, ResizeThumbnail]
|
||||
@@ -4,45 +4,64 @@
|
||||
{% block title %}{{ event.name }}{% endblock %}
|
||||
|
||||
{% block opengraph %}
|
||||
<meta property="og:type" content="activity" />
|
||||
<meta property="og:title" content="{{event.name}}" />
|
||||
<meta property="og:url" content="http://www.kasu.at{{event.get_absolute_url}}" />
|
||||
<meta property="og:image" content="http://www.kasu.at{{ event.get_thumbnail.url }}" />
|
||||
{% if event.description %}<meta property="og:description" content="{{event.description}}" />{% endif %}
|
||||
<meta property="og:type" content="activity" />
|
||||
<meta property="og:title" content="{{event.name}}" />
|
||||
<meta property="og:url" content="http://www.kasu.at{{event.get_absolute_url}}" />
|
||||
<meta property="og:image" content="http://www.kasu.at{{ event.get_thumbnail.url }}" />
|
||||
{% if event.description %}<meta property="og:description" content="{{event.description}}" />{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
|
||||
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block jumbotron_background %}{{ event.get_callout.url }}')}{% endblock %}
|
||||
|
||||
|
||||
{% block jumbotron_background %} {{ event.get_callout.url }} {% endblock %}
|
||||
|
||||
{% block teaser %}
|
||||
<h2>{{event.name}}</h2>
|
||||
<div id="teaser_text">
|
||||
<h1>{{event.name}}</h1>
|
||||
{% if event.description %}
|
||||
{{event.description|markdown}}
|
||||
{% else %}
|
||||
{{event.location.description|markdown}}
|
||||
<div id="teaser_text">{{event.description|markdown}}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block redbox %}
|
||||
<h2>Info</h2>
|
||||
<p> </p>
|
||||
<ul>
|
||||
<li class="date"><strong>{% trans "Start" %}:</strong> {{ event.start }}</li>
|
||||
{% if event.end %}<li class="date"><strong>{% trans "End" %}:</strong> {{ event.end }}</li>{% endif %}
|
||||
<li class="location">
|
||||
{% if event.location.url %}<a href="{{ event.location.url }}">{% else %}<a href="http://maps.google.com/maps?q={{event.location.address|urlencode}}&z=16">{% endif %}
|
||||
<strong>{% trans "Location" %}:</strong> {{event.location.name}}</a>
|
||||
</li>
|
||||
{% if event.url %}<li><a href="{{ event.url }}"><strong>{% trans "Homepage" %}:</strong> {{ event.url }}</a></li>{% endif %}
|
||||
<li class="hanchan"><a href="{% url 'event-hanchan-list' event.pk %}" ><strong>{% trans "Hanchans" %}:</strong> {{ event.hanchan_set.count }}</a></li>
|
||||
<li class="photo"><a href="{% url 'event-photo-list' event.pk %}"><strong>{% trans 'Photos' %}:</strong> {{ event.photo_count }}</a></li>
|
||||
{% if event.is_tournament %}<li class="season"><a href="{% url 'event-ranking' event.pk %}"><strong>{% trans "tourney" %}:</strong> {% trans "other rules apply here" %}</a></li>{% endif%}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block navigation %}
|
||||
<code>{{ event. }}</code>
|
||||
<ul id="navigation">
|
||||
<li><a href="{{ event.get_absolute_url }}"><img src="{{ STATIC_URL }}icons/information.png" alt="{% trans 'Hanchans' %}" /> {% trans 'Info' %}</a></li>
|
||||
<li><a href="{% url 'event-photo-list' event.pk %}"><img src="{{ STATIC_URL }}icons/camera.png" alt="{% trans 'Photos' %}" /> {{ event.photo_count }} {% trans 'Photos' %}</a></li>
|
||||
<li><a href="{% url 'event-hanchan-list' event.pk %}" ><img src="{{ STATIC_URL }}icons/table.png" alt="{% trans 'Hanchans' %}" /> {{ event.hanchan_set.count }} {% trans "Hanchans" %}</a></li>
|
||||
<li><a href="{% url 'maistar-game-list' event.pk %}" ><img src="{{ STATIC_URL }}icons/drink.png" alt="{% trans 'Mai-Star Games' %}" /> {{ event.maistargame_set.count }} {% trans "Mai-Star Games" %}</a></li>
|
||||
|
||||
{% if event.is_tournament %}
|
||||
<li><a href="{% url 'event-ranking' event.id %}"><img src="{{ STATIC_URL }}icons/medal_gold_1.png" alt="{% trans "Tournament Ranking" %}" /> {% trans "Tournament Ranking" %}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{% block maincontent %}
|
||||
<div class="grid_4">
|
||||
<h3>{% trans "Date" %}</h3>
|
||||
<p></p>
|
||||
<ul>
|
||||
<li><strong>{% trans "Start" %}:</strong> {{ event.start }}</li>
|
||||
{% if event.end %}<li><strong>{% trans "End" %}:</strong> {{ event.end }}</li>{% endif %}
|
||||
{% if event.url %}<li><strong>{% trans "Homepage" %}:</strong> <a href="{{ event.url }}">{{ event.url }}</a></li>{% endif %}
|
||||
</ul>
|
||||
<div class="grid_6" id="google_maps">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="grid_4">
|
||||
<div class="grid_6">
|
||||
<h3>{% trans 'Location' %}</h3>
|
||||
<strong>{{ event.location.name }}</strong>
|
||||
<address>
|
||||
@@ -53,28 +72,43 @@
|
||||
{% if event.location.url %}
|
||||
<p><strong>{% trans "Homepage" %}:</strong> <a href="{{ event.location.url }}">{{ event.location.url }}</a></p>
|
||||
{% endif %}
|
||||
<h3>{% trans "Date" %}</h3>
|
||||
<ul>
|
||||
<li><strong>{% trans "Start" %}:</strong> {{ event.start }}</li>
|
||||
{% if event.end %}<li><strong>{% trans "End" %}:</strong> {{ event.end }}</li>{% endif %}
|
||||
{% if event.url %}<li><strong>{% trans "Homepage" %}:</strong> <a href="{{ event.url }}">{{ event.url }}</a></li>{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grid_4 center">
|
||||
<ul class="info">
|
||||
<li><img src="{{ STATIC_URL }}icons/table.png" alt="{% trans 'Hanchans' %}" /><a href="{% url 'event-hanchan-list' event.pk %}" >{{ event.hanchan_set.count }} {% trans "Hanchans" %}</a></li>
|
||||
<li><img src="{{ STATIC_URL }}icons/camera.png" alt="{% trans 'Photos' %}" /><a href="{% url 'event-photo-list' event.pk %}">{{ event.photo_count }} {% trans 'Photos' %}</a></li>
|
||||
</ul>
|
||||
<div class="grid_12">
|
||||
{% if event.description %}
|
||||
{{event.description|markdown}}
|
||||
{% else %}
|
||||
{{event.location.description|markdown}}
|
||||
{% endif %}
|
||||
<p class="more_link">
|
||||
<a href="https://plus.google.com/share?url=http%3A%2F%2Fwww.kasu.at{{event.get_absolute_url|urlencode}}" onclick="javascript:window.open(this.href,
|
||||
'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;"><img src="{{STATIC_URL}}img/google_plus.png" alt="Google+" title="{% trans 'Share on Google+'%}" width="39" height="39"/></a>
|
||||
<a href="https://twitter.com/share?url=http%3A%2F%2Fwww.kasu.at{{event.get_absolute_url|urlencode}}" target='_blank'><img src="{{STATIC_URL}}img/twitter.png" alt="Twitter" title=" {% trans 'Share on Twitter' %}" width="39" height="39"/></a>
|
||||
<a href="http://facebook.com/sharer.php?u=http%3A%2F%2Fwww.kasu.at{{event.get_absolute_url|urlencode}}" target="_blank"><img src="{{STATIC_URL}}img/facebook.png" alt="Facebook" title="{% trans 'Share on Facebook'%}" width="39" height="39"/></a>
|
||||
<a href="http://maps.google.com/maps?q={{event.location.address|urlencode}}&z=16" target="gmaps"><img src="{{ STATIC_URL }}img/google_maps.png" alt="Google Maps" title="{% trans 'Show on Google Maps' %}" width="39" height="39"/></a>
|
||||
</p>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
{% render_comment_list for event %}
|
||||
{% render_comment_form for event %}
|
||||
{% block event_content %} {% endblock %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block comments %}
|
||||
{% render_comment_list for event %}
|
||||
{% render_comment_form for event %}
|
||||
{% endblock %}
|
||||
|
||||
{% block buttonbar %}
|
||||
{% if perms.events.change_event %}
|
||||
<a class="button" href="{{ event.get_edit_url }}"><img src="{{ STATIC_URL }}icons/page_edit.png" alt="" /> {% trans "Edit Event" %}</a>
|
||||
{% endif %}
|
||||
{% if perms.events.change_event %}
|
||||
<a class="button" href="{{ event.get_edit_url }}"><img src="{{ STATIC_URL }}icons/page_edit.png" alt="" /> {% trans "Edit Event" %}</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block javascript %}
|
||||
@@ -103,8 +137,8 @@
|
||||
center: latlng,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
}
|
||||
map = new google.maps.Map(document.getElementById("redbox"), mapOptions);
|
||||
map = new google.maps.Map(document.getElementById("google_maps"), mapOptions);
|
||||
codeAddress();
|
||||
}
|
||||
initialize();
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends "events/page.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% load i18n django_markdown%}
|
||||
|
||||
{% block title %}{{ event.name }}{% endblock %}
|
||||
@@ -20,20 +20,4 @@
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block redbox %}
|
||||
<h2>Info</h2>
|
||||
<p> </p>
|
||||
<ul>
|
||||
<li class="date"><strong>{% trans "Start" %}:</strong> {{ event.start }}</li>
|
||||
{% if event.end %}<li class="date"><strong>{% trans "End" %}:</strong> {{ event.end }}</li>{% endif %}
|
||||
<li class="location">
|
||||
{% if event.location.url %}<a href="{{ event.location.url }}">{% else %}<a href="http://maps.google.com/maps?q={{event.location.address|urlencode}}&z=16">{% endif %}
|
||||
<strong>{% trans "Location" %}:</strong> {{event.location.name}}</a>
|
||||
</li>
|
||||
{% if event.url %}<li><a href="{{ event.url }}"><strong>{% trans "Homepage" %}:</strong> {{ event.url }}</a></li>{% endif %}
|
||||
<li class="hanchan"><a href="{% url 'event-hanchan-list' event.pk %}" ><strong>{% trans "Hanchans" %}:</strong> {{ event.hanchan_set.count }}</a></li>
|
||||
<li class="photo"><a href="{% url 'event-photo-list' event.pk %}"><strong>{% trans 'Photos' %}:</strong> {{ event.photo_count }}</a></li>
|
||||
{% if event.is_tournament %}<li class="season"><a href="{% url 'event-ranking' event.pk %}"><strong>{% trans "tourney" %}:</strong> {% trans "other rules apply here" %}</a></li>{% endif%}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
|
||||
{% block sidebar %}
|
||||
<a href="http://www.google.com/calendar/render?cid=http%3A%2F%2Fwww.kasu.at%2Fevents.ics" target="_blank"><img src="http://www.google.com/calendar/images/ext/gc_button6.gif" alt="0" border="0"></a>
|
||||
<a href="http://www.google.com/calendar/render?cid=http%3A%2F%2Fwww.kasu.at%2Fevents.ics"
|
||||
target="_blank"><img src="http://www.google.com/calendar/images/ext/gc_button6.gif"
|
||||
alt="{% trans 'Add to Google Calendar' %}"></a>
|
||||
{% endblock %}
|
||||
|
||||
{% block additional_buttonbar %}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n comments %}
|
||||
|
||||
{% block maincontent %}
|
||||
<form action="" method="post" class="grid_12">
|
||||
{% csrf_token %}
|
||||
<header>
|
||||
<h1 class="grid_12">Dieses Photo wirklich löschen?</h1>
|
||||
</header>
|
||||
<p>Sind Sie sicher, dass Sie das Bild “{{photo.name}}” löschen wollen?</p>
|
||||
<img src="{{photo.display.url}}" alt="{{photo.name}}" title="{{photo.name}}" class="grid_10 push_1"/>
|
||||
<br class="clear"/>
|
||||
<p> </p>
|
||||
<p class="buttonbar">
|
||||
<a href="{% url 'event-photo-list' photo.event.id %}" class="button" style="float: left;"><img
|
||||
src="{{STATIC_URL}}icons/cancel.png" alt="{% trans 'Cancel' %}"/> {% trans 'Cancel' %}</a>
|
||||
<button type="submit"><img src="{{STATIC_URL}}icons/delete.png" alt="{% trans 'Delete' %}"/>
|
||||
{% trans 'Delete' %}
|
||||
</button>
|
||||
</p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
{% block buttonbar %}{% endblock %}
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
{% extends "events/photo_list.html" %}
|
||||
{% load i18n comments %}
|
||||
|
||||
{% block title %} {{ photo.name }} - {{ photo.event.name }} {% endblock %}
|
||||
|
||||
{% block opengraph %}
|
||||
<meta property="og:type" content="photo" />
|
||||
<meta property="og:title" content="{{photo.name}} - Foto" />
|
||||
<meta property="og:url" content="http://www.kasu.at{{photo.get_absolute_url}}" />
|
||||
<meta property="og:image" content="http://www.kasu.at{{photo.thumbnail.url}}" />
|
||||
{% if photo.description %}<meta property="og:description" content="{{photo.description}}" />{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block maincontent %}
|
||||
<h2 class="grid_12"><a href="{% url 'event-photo-list' photo.event.id %}">{{photo.event.name}}</a> » {{ photo.name }}</h2>
|
||||
<div id="display" class="grid_12 clearfix">
|
||||
<img src="{{photo.display.url}}" alt="{{photo.name}}" title="{{photo.name}}"/>
|
||||
{% if photo.previous_photo %}
|
||||
<a href="{{ photo.previous_photo.get_absolute_url }}" class="previous">{% trans 'previous' %}</a>
|
||||
{% endif %}
|
||||
{% if photo.next_photo %}
|
||||
<a href="{{ photo.next_photo.get_absolute_url }}" class="next">Next</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if perms.events.change_photo %}
|
||||
<form method="post" enctype="multipart/form-data" class="grid_12">
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
{% include "form.html" %}
|
||||
<p class="buttonbar">
|
||||
<a href="{{ photo.image.url }}" class="button" type="application/octet-stream"><img src="{{ STATIC_URL}}icons/drive_go.png" alt="{% trans 'download' %}" title="{% trans 'download' %}" /></a>
|
||||
<button type="submit" name="rotate" value="counter-clockwise"><img src="{{STATIC_URL}}icons/shape_rotate_anticlockwise.png" title="Gegen den Uhrzeiger drehen"></button>
|
||||
<button type="submit" name="rotate" value="clockwise"><img src="{{STATIC_URL}}icons/shape_rotate_clockwise.png" title="Im Uhrzeiger drehen"></button>
|
||||
<button type="submit"><img src="{{STATIC_URL}}icons/disk.png" alt=""> {% trans "save" %}</button>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="grid_10 push_1">{{ photo.description }}</p>
|
||||
|
||||
<ul class="info grid_11 push_1">
|
||||
<li class="user"><strong>{% trans 'Photographer' %}: </strong>{{ photo.photographer }}</li>
|
||||
<li class="date"><strong>{% trans 'on' %}</strong> {{ photo.created_date }}</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
<div class="grid_12 more_link">
|
||||
<a href="https://m.google.com/app/plus/x/?v=compose&content={{photo.headline|urlencode}}+-+http%3A%2F%2Fwww.kasu.at/{{photo.get_absolute_url|urlencode}}" target="_blank"><img src="{{STATIC_URL}}img/google_plus.png" alt="Google+" title="{% trans 'Share on Google+'%}" /></a>
|
||||
<a href="https://twitter.com/share?url=http%3A%2F%2Fwww.kasu.at/{{photo.get_absolute_url|urlencode}}" target='_blank'><img src="{{STATIC_URL}}img/twitter.png" alt="Twitter" title="{% trans 'Share on Twitter' %}" /></a>
|
||||
<a href="http://facebook.com/sharer.php?u=http%3A%2F%2Fwww.kasu.at{{photo.get_absolute_url|urlencode}}" target="_blank"><img src="{{STATIC_URL}}img/facebook.png" alt="Facebook" title="{% trans 'Share on Facebook'%}" /></a>
|
||||
</div>
|
||||
{% render_comment_list for photo %}
|
||||
{% render_comment_form for photo %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block teaser %}<h2>{{page.title}}{% trans 'Photos' %}</h2>{% endblock %}
|
||||
|
||||
{% block navigation %}
|
||||
<ul id="navigation">
|
||||
{% if event %}
|
||||
<li><a href="{{ current_top_page.get_absolute_url }}">{{current_top_page.menu_name}}</a></li>
|
||||
<li><a class="active">{{event.name}}</a></li>
|
||||
{% elif photo %}
|
||||
<li><a href="{{ current_top_page.get_absolute_url }}">{{current_top_page.menu_name}}</a></li>
|
||||
<li><a href="{% url 'event-photo-list' photo.event.id %}">{{photo.event.name}}</a></li>
|
||||
<li><a class="active">{{photo.name}}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ current_top_page.get_absolute_url }}" {% ifequal current_page current_top_page %}class="active"{% endifequal %}>{{current_top_page.menu_name}}</a></li>
|
||||
{% if perms.event.add_photo %}
|
||||
<li><a href="/gallery/upload/" class="{% ifequal current_path 'gallery/upload' %}active{% endifequal %}">{% trans 'Upload' %}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{% block maincontent %}
|
||||
{% for event in event_list %}
|
||||
<div class="gallery grid_4">
|
||||
<h3><a href="{% url 'event-photo-list' event.id %}">{{event.name}}</a></h3>
|
||||
<a href="{% url 'event-photo-list' event.id %}"><img src="{{event.get_thumbnail.url}}" class="thumbnail"/></a>
|
||||
</div>
|
||||
{% empty %}
|
||||
<p>Sorry da kommt erst was hin!</p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block buttonbar %}{% endblock %}
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
{% extends "events/event_site.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{{event.name}}{% endblock %}
|
||||
|
||||
{% block opengraph %}
|
||||
<meta property="og:type" content="album" />
|
||||
<meta property="og:title" content="{{event.name}}" />
|
||||
<meta property="og:url" content="http://www.kasu.at{% url 'event-photo-list' event.pk %}" />
|
||||
<meta property="og:image" content="http://www.kasu.at{{ event.get_thumbnail.url }}" />
|
||||
{% if event.description %}<meta property="og:description" content="{{event.description}}" />{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block navigation %}
|
||||
<ul id="navigation">
|
||||
{% if photo %}
|
||||
<li><a href="{{ current_top_page.get_absolute_url }}">{{current_top_page.menu_name}}</a></li>
|
||||
<li><a href="{% url 'event-photo-list' photo.event.id %}">{{photo.event.name}}</a></li>
|
||||
<li><a class="active">{{photo.name}}</a></li>
|
||||
{% elif event %}
|
||||
<li><a href="{{ current_top_page.get_absolute_url }}">{{current_top_page.menu_name}}</a></li>
|
||||
<li><a class="active">{{event.name}}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{ current_top_page.get_absolute_url }}" {% ifequal current_page current_top_page %}class="active"{% endifequal %}>{{current_top_page.menu_name}}</a></li>
|
||||
{% if perms.event.add_photo %}
|
||||
<li><a href="/gallery/upload/" class="{% ifequal current_path 'gallery/upload' %}active{% endifequal %}">{% trans 'Upload' %}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block maincontent %}
|
||||
{% if perms.events.delete_photo %}
|
||||
{% for photo in photo_list %}
|
||||
<div class="thumbnail">
|
||||
<a href="{{photo.get_absolute_url}}"><img src="{{photo.thumbnail.url}}" alt=""/></a>
|
||||
<a href="{% url 'delete-event-photo' photo.pk %}" class="delete_image"><img src="{{STATIC_URL}}icons/delete.png" title="{% trans 'delete' %}"/></a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for photo in photo_list %}
|
||||
<a href="{{photo.get_absolute_url}}" class="thumbnail"><img src="{{photo.thumbnail.url}}" alt=""/></a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if perms.events.add_photo %}
|
||||
<br class="clear" />
|
||||
<form action="{% url 'event-photo-upload' event.id %}" method="post" enctype="multipart/form-data" class="grid_12">
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
<legend>Photos hochladen</legend>
|
||||
{% include "form.html"%}
|
||||
<p class="buttonbar">
|
||||
<button type="reset"><img src="{{STATIC_URL}}icons/arrow_undo.png" alt="{% trans 'reset' %}" /> {% trans 'reset' %}</button>
|
||||
<button type="submit"><img src="{{STATIC_URL}}icons/image_add.png" alt="{% trans 'upload' %}" /> {% trans 'upload' %}</button>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block buttonbar %}{% endblock %}
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
{% extends "events/photo_gallery.html" %}
|
||||
{% load i18n comments %}
|
||||
|
||||
{% block maincontent %}
|
||||
<h2 class="grid_12">Photos</a> » {% trans "upload"%}</h2>
|
||||
{% for event in event_list %}
|
||||
{% get_comment_count for event as comment_count %}
|
||||
{% ifchanged %}<h3 class="grid_12">{{ event.start|date:'F Y' }}</h3>{% endifchanged %}
|
||||
<div style="float:left">
|
||||
<a href="{% url 'event-photo-list' event.pk %}"><img src="{{ event.get_thumbnail.url }}" alt="" class="thumbnail"/></a>
|
||||
<div class="grid_4" />
|
||||
<h4><a href="{% url 'event-photo-list' event.pk %}">{{ event.name }}</a></h4>
|
||||
<div class="info">
|
||||
<img src="{{ STATIC_URL }}/icons/date.png" alt="{% trans 'Start' %}" title="{% trans 'Start' %}">
|
||||
{{ event.start|date }}
|
||||
{% if event.end %}
|
||||
{% trans "from" %} {{ event.start|time:'H:i' }} {% trans "to" %} {{ event.end|time:'H:i' }}
|
||||
{% else %}
|
||||
{{ event.start|time:'H:i' }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if event.description %}<p>{{event.description}}</p>{% endif %}
|
||||
<div class="info">
|
||||
<img src="{{ STATIC_URL }}/icons/map.png" alt="{% trans 'Location' %}" title="{% trans 'Location' %}">
|
||||
{{ event.location }}
|
||||
<img src="{{ STATIC_URL }}/icons/comments.png" alt="{% trans 'Comments' %}" title="{% trans 'Comments' %}">
|
||||
<a href="{{event.get_absolute_url}}#comments">{{ comment_count }} {% trans 'Comments' %}</a>
|
||||
<img src="{{ STATIC_URL }}/icons/images.png" alt="{% trans 'Photos' %}" title="{% trans 'Photos' %}">
|
||||
<a href="{% url 'event-photo-list' event.pk %}">{{ event.photo_count }} {% trans 'Photos' %}</a>
|
||||
</div>
|
||||
<p style="text-align:right">
|
||||
{% if perms.events.add_photo %}
|
||||
<a href="{% url 'event-photo-list' event.pk %}" class="button"><img src="{{ STATIC_URL }}icons/image_add.png" alt="{%trans "Upload" %}"></a>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div></div>
|
||||
{% endfor %}
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<fieldset class="grid_8 push_2">
|
||||
<legend>Photos hochladen</legend>
|
||||
{% include "form.html" %}
|
||||
<p class="buttonbar">
|
||||
<button type="submit">
|
||||
<img src="{{ STATIC_URL }}icons/drive_go.png" alt="" />
|
||||
{% trans "upload" %}
|
||||
</button>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
19
events/urls.py
Normal file
19
events/urls.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
from django.conf.urls import patterns, url
|
||||
|
||||
from .views import *
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^$', UpcomingEvents.as_view(), name='upcoming-events'),
|
||||
url(r'^(?P<year>[\d]{4})/$', EventArchiveYear.as_view(),
|
||||
name='event-archive'),
|
||||
url(r'^(?P<year>[\d]{4})/(?P<month>[\d]+)/$', EventArchiveMonth.as_view(),
|
||||
name='event-archive'),
|
||||
url(r'^(?P<year>[\d]{4})/(?P<month>[\d]+)/(?P<pk>[\d]+)/$',
|
||||
EventDetail.as_view(), name='event-detail'),
|
||||
url(r'^(?P<year>[\d]{4})/(?P<month>[\d]+)/(?P<pk>[\d]+)/edit/$',
|
||||
EventForm.as_view(), name='event-form'),
|
||||
url(r'^add/$', EventForm.as_view(), name='event-form'),
|
||||
url(r'^archive/$', EventArchiveIndex.as_view(), name='event-archive'),
|
||||
)
|
||||
@@ -15,7 +15,6 @@ from icalendar import Calendar, Event
|
||||
import pyexiv2
|
||||
|
||||
from utils.mixins import PermissionRequiredMixin
|
||||
|
||||
from . import models, forms
|
||||
|
||||
|
||||
@@ -80,9 +79,17 @@ class EventArchiveYear(generic.YearArchiveView):
|
||||
class EventDetail(generic.DetailView):
|
||||
model = models.Event
|
||||
|
||||
|
||||
class EventDetailMixin(object):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = generic.DetailView.get_context_data(self, **kwargs)
|
||||
context['form'] = forms.PhotoUploadForm(initial={'event': self.object, 'photographer': self.request.user})
|
||||
context = super(EventDetailMixin, self).get_context_data(**kwargs)
|
||||
if hasattr(self, 'event'):
|
||||
context['event'] = self.event
|
||||
else:
|
||||
context['event'] = self.object.event
|
||||
print "EventDetailMixin"
|
||||
print dir(context['event'])
|
||||
return context
|
||||
|
||||
|
||||
@@ -108,7 +115,8 @@ class EventForm(PermissionRequiredMixin, generic.UpdateView):
|
||||
|
||||
class EventGallery(generic.ListView):
|
||||
template_name = 'events/photo_gallery.html'
|
||||
queryset = models.Event.objects.filter(start__lt=timezone.now(), photo_count__gt=0)
|
||||
queryset = models.Event.objects.filter(start__lt=timezone.now(),
|
||||
photo_count__gt=0)
|
||||
paginate_by = 12
|
||||
|
||||
|
||||
@@ -156,7 +164,8 @@ class EventPhoto(generic.UpdateView):
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if request.POST.get('rotate') and request.user.has_perm('events.change_photo'):
|
||||
if request.POST.get('rotate') and request.user.has_perm(
|
||||
'events.change_photo'):
|
||||
photo = models.Photo.objects.get(pk=kwargs['pk'])
|
||||
photo.rotate(request.POST['rotate'])
|
||||
# return redirect(photo.get_absolute_url())
|
||||
@@ -172,7 +181,8 @@ class EventPhotoList(generic.ListView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = generic.ListView.get_context_data(self, **kwargs)
|
||||
context['event'] = self.event
|
||||
context['form'] = forms.PhotoUploadForm(initial={'event': self.event, 'photographer': self.request.user})
|
||||
context['form'] = forms.PhotoUploadForm(
|
||||
initial={'event': self.event, 'photographer': self.request.user})
|
||||
return context
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -208,8 +218,10 @@ class EventPhotoUpload(generic.FormView):
|
||||
"""
|
||||
|
||||
"""
|
||||
self.event = models.Event.objects.get(id=self.request.REQUEST.get('event'))
|
||||
photographer = self.request.POST.get('photographer', self.request.user.id)
|
||||
self.event = models.Event.objects.get(
|
||||
id=self.request.REQUEST.get('event'))
|
||||
photographer = self.request.POST.get('photographer',
|
||||
self.request.user.id)
|
||||
photographer = get_user_model().objects.get(id=photographer)
|
||||
self.counter = 1
|
||||
for upload in self.request.FILES.getlist('upload'):
|
||||
|
||||
Reference in New Issue
Block a user