and media.actor != request.user.id \
and request.method != 'POST':
messages.add_message(
- request, messages.WARNING,
+ request,
+ messages.WARNING,
_("You are editing another user's media. Proceed with caution."))
return render_to_response(
media.save()
messages.add_message(
- request, messages.SUCCESS,
- _("You added the attachment %s!") \
- % (form.attachment_name.data
- or request.files['attachment_file'].filename))
+ request,
+ messages.SUCCESS,
+ _("You added the attachment %s!") %
+ (form.attachment_name.data or
+ request.files['attachment_file'].filename))
return redirect(request,
location=media.url_for_self(request.urlgen))
# No need to warn again if admin just submitted an edited profile
if request.method != 'POST':
messages.add_message(
- request, messages.WARNING,
+ request,
+ messages.WARNING,
_("You are editing a user's profile. Proceed with caution."))
user = url_user
user.save()
- messages.add_message(request,
- messages.SUCCESS,
- _("Profile changes saved"))
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _("Profile changes saved"))
return redirect(request,
'mediagoblin.user_pages.user_home',
user=user.username)
user.license_preference = form.license_preference.data
user.save()
- messages.add_message(request,
- messages.SUCCESS,
- _("Account settings saved"))
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _("Account settings saved"))
return redirect(request,
'mediagoblin.user_pages.user_home',
user=user.username)
else: # Did not check the confirmation box...
messages.add_message(
- request, messages.WARNING,
+ request,
+ messages.WARNING,
_('You need to confirm the deletion of your account.'))
# No POST submission or not confirmed, just show page
if existing_collection and existing_collection.id != collection.id:
messages.add_message(
- request, messages.ERROR,
- _('You already have a collection called "%s"!') % \
+ request,
+ messages.ERROR,
+ _('You already have a collection called "%s"!') %
form.title.data)
elif slug_used:
form.slug.errors.append(
and collection.actor != request.user.id \
and request.method != 'POST':
messages.add_message(
- request, messages.WARNING,
- _("You are editing another user's collection. Proceed with caution."))
+ request,
+ messages.WARNING,
+ _("You are editing another user's collection. "
+ "Proceed with caution."))
return render_to_response(
request,
may_edit_blogpost, set_blogpost_state, get_all_blogposts_of_blog,
get_blog_by_slug)
-from mediagoblin.messages import add_message, SUCCESS, ERROR, WARNING
from mediagoblin.decorators import (require_active_login, active_user_from_url,
get_media_entry_by_id, user_may_alter_collection,
get_user_collection, uses_pagination)
user=request.user.username
)
else:
- add_message(request, ERROR, "Welcome! You already have created \
- maximum number of blogs.")
+ messages.add_message(
+ request,
+ messages.ERROR,
+ "Welcome! You already have created maximum number of blogs.")
return redirect(request, "mediagoblin.media_types.blog.blog_admin_dashboard",
user=request.user.username)
blog.generate_slug()
blog.save()
- add_message(request, SUCCESS, "Your blog is updated.")
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ "Your blog is updated.")
return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
user=request.user.username,
blog_slug=blog.slug)
blog_post_data.media_entry = blogpost.id
blog_post_data.save()
- add_message(request, SUCCESS, _('Woohoo! Submitted!'))
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _('Woohoo! Submitted!'))
add_comment_subscription(request.user, blogpost)
return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
user=request.user.username,
blogpost.generate_slug()
blogpost.save()
- add_message(request, SUCCESS, _('Woohoo! edited blogpost is submitted'))
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _('Woohoo! edited blogpost is submitted'))
return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
user=request.user.username,
blog_slug=blog.slug)
if request.method == 'POST' and form.validate():
if form.confirm.data is True:
blog.delete()
- add_message(
- request, SUCCESS, _('You deleted the Blog.'))
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _('You deleted the Blog.'))
return redirect(request, "mediagoblin.media_types.blog.blog_admin_dashboard",
user=request.user.username)
else:
- add_message(
- request, ERROR,
- _("The media was not deleted because you didn't check that you were sure."))
+ messages.add_message(
+ request,
+ messages.ERROR,
+ _("The media was not deleted because you didn't check "
+ "that you were sure."))
return redirect(request, "mediagoblin.media_types.blog.blog_admin_dashboard",
user=request.user.username)
else:
if request.user.has_privilege(u'admin'):
- add_message(
- request, WARNING,
+ messages.add_message(
+ request,
+ messages.WARNING,
_("You are about to delete another user's Blog. "
"Proceed with caution."))
return render_to_response(
'form':form
})
else:
- add_message(
- request, ERROR,
- _("The blog was not deleted because you have no rights."))
+ messages.add_message(
+ request,
+ messages.ERROR,
+ _("The blog was not deleted because you have no rights."))
return redirect(request, "mediagoblin.media_types.blog.blog_admin_dashboard",
user=request.user.username)
add_comment_subscription(request.user, media)
- messages.add_message(request,
- messages.SUCCESS,
- _('Subscribed to comments on %s!')
- % media.title)
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _('Subscribed to comments on %s!') % media.title)
return redirect(request, location=media.url_for_self(request.urlgen))
def silence_comments(request, media):
silence_comment_subscription(request.user, media)
- messages.add_message(request,
- messages.SUCCESS,
- _('You will not receive notifications for comments on'
- ' %s.') % media.title)
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _('You will not receive notifications for comments on %s.') %
+ media.title)
return redirect(request, location=media.url_for_self(request.urlgen))
username=fp_form.username.data).first()
if user is None:
- messages.add_message(request,
- messages.WARNING,
- _("Couldn't find someone with that username."))
+ messages.add_message(
+ request,
+ messages.WARNING,
+ _("Couldn't find someone with that username."))
return redirect(request,
'mediagoblin.plugins.basic_auth.forgot_password')
if user and user.has_privilege(u'active') is False:
# Don't send reminder because user is inactive or has no verified email
- messages.add_message(request,
+ messages.add_message(
+ request,
messages.WARNING,
- _("Could not send password recovery email as your username is in"
- "active or your account's email address has not been verified."))
+ _("Could not send password recovery email as your username is "
+ "inactive or your account's email address has not been verified."))
return redirect(request, 'mediagoblin.user_pages.user_home',
user=user.username)
#
# if not user.email_verified:
# messages.add_message(
- # request, messages.ERROR,
+ # request,
+ # messages.ERROR,
# _('You need to verify your email before you can reset your'
# ' password.'))
if not user.status == 'active':
messages.add_message(
- request, messages.ERROR,
- _('You are no longer an active user. Please contact the system'
- ' admin to reactivate your account.'))
+ request,
+ messages.ERROR,
+ _("You are no longer an active user. Please contact the system "
+ "admin to reactivate your account."))
return redirect(
request, 'index')
user.save()
messages.add_message(
- request, messages.SUCCESS,
+ request,
+ messages.SUCCESS,
_('Your password was changed successfully'))
return redirect(request, 'mediagoblin.edit.account')
from mediagoblin.tools.response import render_to_response, redirect
from mediagoblin.decorators import require_active_login, user_has_privilege
from mediagoblin.submit import forms as submit_forms
-from mediagoblin.messages import add_message, SUCCESS
from mediagoblin.media_types import FileTypeNotSupported
from mediagoblin.submit.lib import \
check_file_field, submit_media, get_upload_file_limits, \
"add", media, request.user,
target=submit_form.collection.data)
- add_message(request, SUCCESS, _('Woohoo! Submitted!'))
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _('Woohoo! Submitted!'))
return redirect(request, "mediagoblin.user_pages.user_home",
user=request.user.username)
title=collection.title).first()
if existing_collection:
- add_message(request, messages.ERROR,
- _('You already have a collection called "%s"!') \
- % collection.title)
+ messages.add_message(
+ request,
+ messages.ERROR,
+ _('You already have a collection called "%s"!') %
+ collection.title)
else:
collection.save()
- add_message(request, SUCCESS,
+ messages.add_message(
+ request,
+ messages.SUCCESS,
_('Collection "%s" added!') % collection.title)
return redirect(request, "mediagoblin.user_pages.user_home",
"""
if mg_globals.app_config['email_debug_mode']:
# DEBUG message, no need to translate
- messages.add_message(request, messages.DEBUG,
+ messages.add_message(
+ request,
+ messages.DEBUG,
"This instance is running in email debug mode. "
"The email will be on the console of the server process.")
link.save()
messages.add_message(
- request, messages.SUCCESS,
+ request,
+ messages.SUCCESS,
_('Your comment has been posted!'))
trigger_notification(link, media, request)
if request.method != 'POST' or not form.validate():
# No POST submission, or invalid form
if not form.validate():
- messages.add_message(request, messages.ERROR,
+ messages.add_message(
+ request,
+ messages.ERROR,
_('Please check your entries and try again.'))
return render_to_response(
type=Collection.USER_DEFINED_TYPE
).first()
if existing_collection:
- messages.add_message(request, messages.ERROR,
- _('You already have a collection called "%s"!')
- % existing_collection.title)
+ messages.add_message(
+ request,
+ messages.ERROR,
+ _('You already have a collection called "%s"!') %
+ existing_collection.title)
return redirect(request, "mediagoblin.user_pages.media_home",
user=media.get_actor.username,
media=media.slug_or_id)
if not collection:
messages.add_message(
- request, messages.ERROR,
+ request,
+ messages.ERROR,
_('You have to select or add a collection'))
return redirect(request, "mediagoblin.user_pages.media_collect",
user=media.get_actor.username,
# Check whether media already exists in collection
elif item is not None:
- messages.add_message(request, messages.ERROR,
- _('"%s" already in collection "%s"')
- % (media.title, collection.title))
+ messages.add_message(
+ request,
+ messages.ERROR,
+ _('"%s" already in collection "%s"') %
+ (media.title, collection.title))
else: # Add item to collection
add_media_to_collection(collection, media, form.note.data)
create_activity("add", media, request.user, target=collection)
- messages.add_message(request, messages.SUCCESS,
- _('"%s" added to collection "%s"')
- % (media.title, collection.title))
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _('"%s" added to collection "%s"') %
+ (media.title, collection.title))
return redirect_obj(request, media)
# Delete MediaEntry and all related files, comments etc.
media.delete()
messages.add_message(
- request, messages.SUCCESS, _('You deleted the media.'))
+ request,
+ messages.SUCCESS,
+ _('You deleted the media.'))
location = media.url_to_next(request.urlgen)
if not location:
return redirect(request, location=location)
else:
messages.add_message(
- request, messages.ERROR,
- _("The media was not deleted because you didn't check that you were sure."))
+ request,
+ messages.ERROR,
+ _("The media was not deleted because you didn't check "
+ "that you were sure."))
return redirect_obj(request, media)
if ((request.user.has_privilege(u'admin') and
request.user.id != media.actor)):
messages.add_message(
- request, messages.WARNING,
+ request,
+ messages.WARNING,
_("You are about to delete another user's media. "
"Proceed with caution."))
collection.save()
messages.add_message(
- request, messages.SUCCESS, _('You deleted the item from the collection.'))
+ request,
+ messages.SUCCESS,
+ _('You deleted the item from the collection.'))
else:
messages.add_message(
- request, messages.ERROR,
- _("The item was not removed because you didn't check that you were sure."))
+ request,
+ messages.ERROR,
+ _("The item was not removed because you didn't check "
+ "that you were sure."))
return redirect_obj(request, collection)
if ((request.user.has_privilege(u'admin') and
request.user.id != collection_item.in_collection.actor)):
messages.add_message(
- request, messages.WARNING,
+ request,
+ messages.WARNING,
_("You are about to delete an item from another user's collection. "
"Proceed with caution."))
item.delete()
collection.delete()
- messages.add_message(request, messages.SUCCESS,
- _('You deleted the collection "%s"') % collection_title)
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ _('You deleted the collection "%s"') %
+ collection_title)
return redirect(request, "mediagoblin.user_pages.user_home",
user=username)
else:
messages.add_message(
- request, messages.ERROR,
- _("The collection was not deleted because you didn't check that you were sure."))
+ request,
+ messages.ERROR,
+ _("The collection was not deleted because you didn't "
+ "check that you were sure."))
return redirect_obj(request, collection)