Source code for mg.media.photo.views

# -*- coding:utf-8 -*-

# MG_GPL_HEADER_BEGIN
# 
# This file is part of Media Gallery, GNU GPLv2.
# 
# Media Gallery is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# 
# Media Gallery is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Media Gallery; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# 
# MG_GPL_HEADER_END

__author__ = "Media Gallery contributors <mg@lists.ssji.net>"
__copyright__ = "(c) 2011"
__credits__ = ["Dimitri Refauvelet", "Nicolas Pouillon"]

from django.views.generic.list_detail import object_detail, object_list
from django.http import HttpResponse
from mg.core.element.models import Element
from models import *

from mg.utils.redirect import redirect_to_referer

from django.utils import simplejson
from django.contrib.admin.views.decorators import staff_member_required

@staff_member_required
def bottom_side_update(request, object_id):
[docs] post = request.POST.copy() photo = Photo.objects.get(pk = object_id) if post.has_key('bottom_side'): bottom_side = post['bottom_side'] if photo.bottom_side != bottom_side: photo.bottom_side = bottom_side photo.save() photo.rehash_all_resized() d = dict( msg = 'Update successful!', thumb = photo.thumbnail_get().file.url, bs = photo.bottom_side, ) return HttpResponse(simplejson.dumps(d)) @staff_member_required
def bottom_side_review(request):
[docs] return object_list(request, queryset = Photo.objects.all().order_by("pk"), paginate_by = 66, template_name = "photo/bottom_side_review.html", ) def prefer_size(request):
[docs] try: width, height = request.GET["width"], request.GET["height"] size = PhotoSize.objects.get(width = width, height = height) request.session['resizedphoto_size_pk'] = size.pk except: pass return redirect_to_referer(request, "/")