Style fixes

This commit is contained in:
Joar Wandborg 2012-09-18 18:19:26 +02:00
parent c9ac6841c4
commit 6d1e55b262
2 changed files with 34 additions and 21 deletions

View File

@ -188,6 +188,7 @@ class CollectionMixin(object):
collection=self.slug_or_id,
**extra_args)
class CollectionItemMixin(object):
@property
def note_html(self):

View File

@ -34,7 +34,6 @@ from mediagoblin.decorators import (uses_pagination, get_user_media_entry,
from werkzeug.contrib.atom import AtomFeed
from mediagoblin.media_types import get_media_manager
from sqlalchemy.exc import IntegrityError
_log = logging.getLogger(__name__)
_log.setLevel(logging.DEBUG)
@ -129,7 +128,8 @@ def media_home(request, media, page, **kwargs):
comment_form = user_forms.MediaCommentForm(request.POST)
media_template_name = get_media_manager(media.media_type)['display_template']
media_template_name = get_media_manager(
media.media_type)['display_template']
return render_to_response(
request,
@ -182,7 +182,8 @@ def media_collect(request, media):
form = user_forms.MediaCollectForm(request.POST)
filt = (request.db.Collection.creator == request.user.id)
form.collection.query = request.db.Collection.query.filter(filt).order_by(request.db.Collection.title)
form.collection.query = request.db.Collection.query.filter(
filt).order_by(request.db.Collection.title)
if request.method == 'POST':
if form.validate():
@ -196,10 +197,10 @@ def media_collect(request, media):
collection.id = ObjectId()
collection.title = (
unicode(request.POST['collection_title'])
or unicode(splitext(filename)[0]))
unicode(request.POST['collection_title']))
collection.description = unicode(request.POST.get('collection_description'))
collection.description = unicode(
request.POST.get('collection_description'))
collection.creator = request.user._id
collection.generate_slug()
@ -210,7 +211,9 @@ def media_collect(request, media):
if existing_collection:
messages.add_message(
request, messages.ERROR, _('You already have a collection called "%s"!' % collection.title))
request, messages.ERROR,
_('You already have a collection called "%s"!'
% collection.title))
return redirect(request, "mediagoblin.user_pages.media_home",
user=request.user.username,
@ -221,17 +224,23 @@ def media_collect(request, media):
collection_item.collection = collection.id
# Otherwise, use the collection selected from the drop-down
else:
collection = request.db.Collection.find_one({'_id': request.POST.get('collection')})
collection = request.db.Collection.find_one({
'_id': request.POST.get('collection')})
collection_item.collection = collection.id
# Make sure the user actually selected a collection
if not collection:
messages.add_message(
request, messages.ERROR, _('You have to select or add a collection'))
request, messages.ERROR,
_('You have to select or add a collection'))
# Check whether media already exists in collection
elif request.db.CollectionItem.find_one({'media_entry': media.id, 'collection': collection_item.collection}):
elif request.db.CollectionItem.find_one({
'media_entry': media.id,
'collection': collection_item.collection}):
messages.add_message(
request, messages.ERROR, _('"%s" already in collection "%s"' % (media.title, collection.title)))
request, messages.ERROR,
_('"%s" already in collection "%s"'
% (media.title, collection.title)))
else:
collection_item.media_entry = media.id
collection_item.author = request.user.id
@ -245,14 +254,16 @@ def media_collect(request, media):
media.save()
messages.add_message(
request, messages.SUCCESS, _('"%s" added to collection "%s"' % (media.title, collection.title)))
request, messages.SUCCESS, _('"%s" added to collection "%s"'
% (media.title, collection.title)))
return redirect(request, "mediagoblin.user_pages.media_home",
user=media.get_uploader.username,
media=media.id)
else:
messages.add_message(
request, messages.ERROR, _('Please check your entries and try again.'))
request, messages.ERROR,
_('Please check your entries and try again.'))
return render_to_response(
request,
@ -361,7 +372,7 @@ def collection_item_confirm_remove(request, collection_item):
entry.save()
collection_item.delete()
collection.items = collection.items - 1;
collection.items = collection.items - 1
collection.save()
messages.add_message(
@ -505,6 +516,7 @@ def atom_feed(request):
return feed.get_response()
def collection_atom_feed(request):
"""
generates the atom feed with the newest images from a collection