Skip to content

Commit 9e4d655

Browse files
committed
Update10
1 parent 72c5f23 commit 9e4d655

File tree

310 files changed

+41068
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+41068
-0
lines changed

events/__init__.py

Whitespace-only changes.

events/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

events/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class EventsConfig(AppConfig):
5+
name = 'events'

events/migrations/__init__.py

Whitespace-only changes.

events/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

events/templates/events/events.html

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{% extends 'base.html' %}
2+
{% load static %}
3+
{% load pinax_events_tags %}
4+
5+
{% block title %}
6+
Events
7+
{% endblock %}
8+
9+
10+
{% block content %}
11+
{% spaceless %}
12+
<br > <br >
13+
14+
<div class="container">
15+
<center><h2 class="title">Upcoming Events</h1></center>
16+
17+
{% events as event_items %}
18+
<center>
19+
<section class="event-list">
20+
{% for event in event_items %}
21+
<li>
22+
<h3><a href="{{ event.url }}">{{ event.title }}</a></h2>
23+
</li>
24+
<article class="event" style="{% if event.secondary_image_thumb %}background-image:url({% static event.secondary_image_thumb.url %});{% endif %}">
25+
<section class="event-img">
26+
<a href="{{ event.url }}">
27+
{% if event.image_thumb %}<img src="{{ event.image_thumb.url }}" width="400" />{% endif %}
28+
</a>
29+
</section>
30+
<br >
31+
<ul class="event-details">
32+
<li class="meta">
33+
<span>
34+
Where: {{ event.where }}
35+
</span>
36+
<br >
37+
<span>
38+
When: {{ event.start_date }} &mdash; {{ event.end_date }}
39+
</span>
40+
</li>
41+
<li class="event-description">
42+
{{ event.what_html|safe|linebreaks }}
43+
<br >
44+
<hr style="background-color: #fff;border-top: 2px dashed #8c8b8b;">
45+
</li>
46+
</ul>
47+
</article>
48+
{% endfor %}
49+
</section>
50+
</center>
51+
</div>
52+
<br />
53+
54+
{% endspaceless %}
55+
{% endblock %}

events/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

events/urls.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.urls import path
2+
from . import views
3+
4+
app_name = 'events'
5+
6+
7+
urlpatterns = [
8+
9+
path('', views.events, name='events')
10+
11+
]

events/views.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.shortcuts import render
2+
3+
4+
def events(request):
5+
context = {}
6+
template_name = 'events/events.html'
7+
return render(request, template_name, context)
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Signature: 8a477f597d28d172789f06886806bc55
Loading
Loading
Loading

photologue/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
3+
__version__ = '3.8.1'
4+
5+
PHOTOLOGUE_APP_DIR = os.path.dirname(os.path.abspath(__file__))

photologue/admin.py

+274
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
from django import forms
2+
from django.conf import settings
3+
from django.conf.urls import url
4+
from django.contrib import admin
5+
from django.contrib.sites.models import Site
6+
from django.contrib import messages
7+
from django.utils.translation import ungettext, ugettext_lazy as _
8+
from django.shortcuts import render
9+
from django.contrib.admin import helpers
10+
from django.http import HttpResponseRedirect
11+
12+
from .models import Gallery, Photo, PhotoEffect, PhotoSize, \
13+
Watermark
14+
from .forms import UploadZipForm
15+
16+
MULTISITE = getattr(settings, 'PHOTOLOGUE_MULTISITE', False)
17+
18+
19+
class GalleryAdminForm(forms.ModelForm):
20+
21+
class Meta:
22+
model = Gallery
23+
if MULTISITE:
24+
exclude = []
25+
else:
26+
exclude = ['sites']
27+
28+
29+
class GalleryAdmin(admin.ModelAdmin):
30+
list_display = ('title', 'date_added', 'photo_count', 'is_public')
31+
list_filter = ['date_added', 'is_public']
32+
if MULTISITE:
33+
list_filter.append('sites')
34+
date_hierarchy = 'date_added'
35+
prepopulated_fields = {'slug': ('title',)}
36+
form = GalleryAdminForm
37+
if MULTISITE:
38+
filter_horizontal = ['sites']
39+
if MULTISITE:
40+
actions = [
41+
'add_to_current_site',
42+
'add_photos_to_current_site',
43+
'remove_from_current_site',
44+
'remove_photos_from_current_site'
45+
]
46+
47+
def formfield_for_manytomany(self, db_field, request, **kwargs):
48+
""" Set the current site as initial value. """
49+
if db_field.name == "sites":
50+
kwargs["initial"] = [Site.objects.get_current()]
51+
return super(GalleryAdmin, self).formfield_for_manytomany(db_field, request, **kwargs)
52+
53+
def save_related(self, request, form, *args, **kwargs):
54+
"""
55+
If the user has saved a gallery with a photo that belongs only to
56+
different Sites - it might cause much confusion. So let them know.
57+
"""
58+
super(GalleryAdmin, self).save_related(request, form, *args, **kwargs)
59+
orphaned_photos = form.instance.orphaned_photos()
60+
if orphaned_photos:
61+
msg = ungettext(
62+
'The following photo does not belong to the same site(s)'
63+
' as the gallery, so will never be displayed: %(photo_list)s.',
64+
'The following photos do not belong to the same site(s)'
65+
' as the gallery, so will never be displayed: %(photo_list)s.',
66+
len(orphaned_photos)
67+
) % {'photo_list': ", ".join([photo.title for photo in orphaned_photos])}
68+
messages.warning(request, msg)
69+
70+
def add_to_current_site(modeladmin, request, queryset):
71+
current_site = Site.objects.get_current()
72+
current_site.gallery_set.add(*queryset)
73+
msg = ungettext(
74+
"The gallery has been successfully added to %(site)s",
75+
"The galleries have been successfully added to %(site)s",
76+
len(queryset)
77+
) % {'site': current_site.name}
78+
messages.success(request, msg)
79+
80+
add_to_current_site.short_description = \
81+
_("Add selected galleries to the current site")
82+
83+
def remove_from_current_site(modeladmin, request, queryset):
84+
current_site = Site.objects.get_current()
85+
current_site.gallery_set.remove(*queryset)
86+
msg = ungettext(
87+
"The gallery has been successfully removed from %(site)s",
88+
"The selected galleries have been successfully removed from %(site)s",
89+
len(queryset)
90+
) % {'site': current_site.name}
91+
messages.success(request, msg)
92+
93+
remove_from_current_site.short_description = \
94+
_("Remove selected galleries from the current site")
95+
96+
def add_photos_to_current_site(modeladmin, request, queryset):
97+
photos = Photo.objects.filter(galleries__in=queryset)
98+
current_site = Site.objects.get_current()
99+
current_site.photo_set.add(*photos)
100+
msg = ungettext(
101+
'All photos in gallery %(galleries)s have been successfully added to %(site)s',
102+
'All photos in galleries %(galleries)s have been successfully added to %(site)s',
103+
len(queryset)
104+
) % {
105+
'site': current_site.name,
106+
'galleries': ", ".join(["'{0}'".format(gallery.title)
107+
for gallery in queryset])
108+
}
109+
messages.success(request, msg)
110+
111+
add_photos_to_current_site.short_description = \
112+
_("Add all photos of selected galleries to the current site")
113+
114+
def remove_photos_from_current_site(modeladmin, request, queryset):
115+
photos = Photo.objects.filter(galleries__in=queryset)
116+
current_site = Site.objects.get_current()
117+
current_site.photo_set.remove(*photos)
118+
msg = ungettext(
119+
'All photos in gallery %(galleries)s have been successfully removed from %(site)s',
120+
'All photos in galleries %(galleries)s have been successfully removed from %(site)s',
121+
len(queryset)
122+
) % {
123+
'site': current_site.name,
124+
'galleries': ", ".join(["'{0}'".format(gallery.title)
125+
for gallery in queryset])
126+
}
127+
messages.success(request, msg)
128+
129+
remove_photos_from_current_site.short_description = \
130+
_("Remove all photos in selected galleries from the current site")
131+
132+
admin.site.register(Gallery, GalleryAdmin)
133+
134+
135+
class PhotoAdminForm(forms.ModelForm):
136+
137+
class Meta:
138+
model = Photo
139+
if MULTISITE:
140+
exclude = []
141+
else:
142+
exclude = ['sites']
143+
144+
145+
class PhotoAdmin(admin.ModelAdmin):
146+
list_display = ('title', 'date_taken', 'date_added',
147+
'is_public', 'view_count', 'admin_thumbnail')
148+
list_filter = ['date_added', 'is_public']
149+
if MULTISITE:
150+
list_filter.append('sites')
151+
search_fields = ['title', 'slug', 'caption']
152+
list_per_page = 10
153+
prepopulated_fields = {'slug': ('title',)}
154+
readonly_fields = ('date_taken',)
155+
form = PhotoAdminForm
156+
if MULTISITE:
157+
filter_horizontal = ['sites']
158+
if MULTISITE:
159+
actions = ['add_photos_to_current_site', 'remove_photos_from_current_site']
160+
161+
def formfield_for_manytomany(self, db_field, request, **kwargs):
162+
""" Set the current site as initial value. """
163+
if db_field.name == "sites":
164+
kwargs["initial"] = [Site.objects.get_current()]
165+
return super(PhotoAdmin, self).formfield_for_manytomany(db_field, request, **kwargs)
166+
167+
def add_photos_to_current_site(modeladmin, request, queryset):
168+
current_site = Site.objects.get_current()
169+
current_site.photo_set.add(*queryset)
170+
msg = ungettext(
171+
'The photo has been successfully added to %(site)s',
172+
'The selected photos have been successfully added to %(site)s',
173+
len(queryset)
174+
) % {'site': current_site.name}
175+
messages.success(request, msg)
176+
177+
add_photos_to_current_site.short_description = \
178+
_("Add selected photos to the current site")
179+
180+
def remove_photos_from_current_site(modeladmin, request, queryset):
181+
current_site = Site.objects.get_current()
182+
current_site.photo_set.remove(*queryset)
183+
msg = ungettext(
184+
'The photo has been successfully removed from %(site)s',
185+
'The selected photos have been successfully removed from %(site)s',
186+
len(queryset)
187+
) % {'site': current_site.name}
188+
messages.success(request, msg)
189+
190+
remove_photos_from_current_site.short_description = \
191+
_("Remove selected photos from the current site")
192+
193+
def get_urls(self):
194+
urls = super(PhotoAdmin, self).get_urls()
195+
custom_urls = [
196+
url(r'^upload_zip/$',
197+
self.admin_site.admin_view(self.upload_zip),
198+
name='photologue_upload_zip')
199+
]
200+
return custom_urls + urls
201+
202+
def upload_zip(self, request):
203+
204+
context = {
205+
'title': _('Upload a zip archive of photos'),
206+
'app_label': self.model._meta.app_label,
207+
'opts': self.model._meta,
208+
'has_change_permission': self.has_change_permission(request)
209+
}
210+
211+
# Handle form request
212+
if request.method == 'POST':
213+
form = UploadZipForm(request.POST, request.FILES)
214+
if form.is_valid():
215+
form.save(request=request)
216+
return HttpResponseRedirect('..')
217+
else:
218+
form = UploadZipForm()
219+
context['form'] = form
220+
context['adminform'] = helpers.AdminForm(form,
221+
list([(None, {'fields': form.base_fields})]),
222+
{})
223+
return render(request, 'admin/photologue/photo/upload_zip.html', context)
224+
225+
226+
admin.site.register(Photo, PhotoAdmin)
227+
228+
229+
class PhotoEffectAdmin(admin.ModelAdmin):
230+
list_display = ('name', 'description', 'color', 'brightness',
231+
'contrast', 'sharpness', 'filters', 'admin_sample')
232+
fieldsets = (
233+
(None, {
234+
'fields': ('name', 'description')
235+
}),
236+
('Adjustments', {
237+
'fields': ('color', 'brightness', 'contrast', 'sharpness')
238+
}),
239+
('Filters', {
240+
'fields': ('filters',)
241+
}),
242+
('Reflection', {
243+
'fields': ('reflection_size', 'reflection_strength', 'background_color')
244+
}),
245+
('Transpose', {
246+
'fields': ('transpose_method',)
247+
}),
248+
)
249+
250+
admin.site.register(PhotoEffect, PhotoEffectAdmin)
251+
252+
253+
class PhotoSizeAdmin(admin.ModelAdmin):
254+
list_display = ('name', 'width', 'height', 'crop', 'pre_cache', 'effect', 'increment_count')
255+
fieldsets = (
256+
(None, {
257+
'fields': ('name', 'width', 'height', 'quality')
258+
}),
259+
('Options', {
260+
'fields': ('upscale', 'crop', 'pre_cache', 'increment_count')
261+
}),
262+
('Enhancements', {
263+
'fields': ('effect', 'watermark',)
264+
}),
265+
)
266+
267+
admin.site.register(PhotoSize, PhotoSizeAdmin)
268+
269+
270+
class WatermarkAdmin(admin.ModelAdmin):
271+
list_display = ('name', 'opacity', 'style')
272+
273+
274+
admin.site.register(Watermark, WatermarkAdmin)

0 commit comments

Comments
 (0)