本文整理汇总了Python中misago.messages.success函数的典型用法代码示例。如果您正苦于以下问题:Python success函数的具体用法?Python success怎么用?Python success使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了success函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: thread_action_move
def thread_action_move(self):
message = None
if self.request.POST.get('do') == 'move':
form = MoveThreadsForm(self.request.POST, request=self.request, forum=self.forum)
if form.is_valid():
new_forum = form.cleaned_data['new_forum']
self.thread.move_to(new_forum)
self.thread.save(force_update=True)
self.thread.set_checkpoint(self.request, 'moved', forum=self.forum)
self.forum.sync()
self.forum.save(force_update=True)
new_forum.sync()
new_forum.save(force_update=True)
messages.success(self.request, _('Thread has been moved to "%(forum)s".') % {'forum': new_forum.name}, 'threads')
return None
message = Message(form.non_field_errors()[0], messages.ERROR)
else:
form = MoveThreadsForm(request=self.request, forum=self.forum)
return render_to_response('%ss/move_thread.html' % self.type_prefix,
{
'type_prefix': self.type_prefix,
'message': message,
'forum': self.forum,
'parents': self.parents,
'thread': self.thread,
'form': form,
},
context_instance=RequestContext(self.request));
开发者ID:dopestz,项目名称:Misago-1,代码行数:28,代码来源:thread.py
示例2: ignore
def ignore(request, user):
if request.user.pk == user.pk:
return error404(request)
if not request.user.is_ignoring(user):
messages.success(request, _("You are now ignoring %(username)s") % {'username': user.username})
request.user.ignores.add(user)
return fallback(request)
开发者ID:0x1330,项目名称:Misago,代码行数:7,代码来源:views.py
示例3: signature
def signature(request):
# Intercept all requests if we can't use signature
if not request.acl.usercp.can_use_signature():
return error403(request)
if request.user.signature_ban:
return render_to_response('usercp/signature_banned.html',
context_instance=RequestContext(request, {
'tab': 'signature'}));
siggy_text = ''
message = request.messages.get_message('usercp_signature')
if request.method == 'POST':
form = SignatureForm(request.POST, request=request, initial={'signature': request.user.signature})
if form.is_valid():
request.user.signature = form.cleaned_data['signature']
if request.user.signature:
request.user.signature_preparsed = signature_markdown(request.acl,
request.user.signature)
else:
request.user.signature_preparsed = None
request.user.save(force_update=True)
messages.success(request, _("Your signature has been changed."), 'usercp_signature')
return redirect(reverse('usercp_signature'))
else:
message = Message(form.non_field_errors()[0], messages.ERROR)
else:
form = SignatureForm(request=request, initial={'signature': request.user.signature})
return render_to_response('usercp/signature.html',
context_instance=RequestContext(request, {
'message': message,
'tab': 'signature',
'form': form}));
开发者ID:0x1330,项目名称:Misago,代码行数:33,代码来源:views.py
示例4: action_move
def action_move(self, ids):
threads = []
for thread in self.threads:
if thread.pk in ids:
threads.append(thread)
if self.request.POST.get('origin') == 'move_form':
form = MoveThreadsForm(self.request.POST, request=self.request, forum=self.forum)
if form.is_valid():
new_forum = form.cleaned_data['new_forum']
for thread in threads:
thread.move_to(new_forum)
thread.save(force_update=True)
thread.set_checkpoint(self.request, 'moved', forum=self.forum)
thread.update_current_dates()
new_forum.sync()
new_forum.save(force_update=True)
self.forum.sync()
self.forum.save(force_update=True)
messages.success(self.request, _('Selected threads have been moved to "%(forum)s".') % {'forum': new_forum.name}, 'threads')
return None
self.message = Message(form.non_field_errors()[0], messages.ERROR)
else:
form = MoveThreadsForm(request=self.request, forum=self.forum)
return render_to_response('%ss/move_threads.html' % self.type_prefix,
{
'type_prefix': self.type_prefix,
'search_in': self.search_in,
'message': self.message,
'forum': self.forum,
'parents': self.parents,
'threads': threads,
'form': form,
},
context_instance=RequestContext(self.request));
开发者ID:dopestz,项目名称:Misago-1,代码行数:34,代码来源:moderation.py
示例5: destroy_user
def destroy_user(request, user, username):
try:
user = User.objects.get(pk=user)
except User.DoesNotExist:
return error404(request)
if user.pk == request.user.pk:
return error403(request, _("You can't destroy your own account."))
try:
request.acl.destroy_users.allow_destroy_user(user)
except ACLError403 as e:
return error403(request, unicode(e))
forums_to_sync = []
for thread in user.thread_set.iterator():
if not thread.forum_id in forums_to_sync:
forums_to_sync.append(thread.forum_id)
thread.delete()
if forums_to_sync:
for forum in Forum.objects.filter(id__in=forums_to_sync).iterator():
forum.sync()
forum.save()
user.post_set.update(deleted=True)
user.delete()
messages.success(request, _('User Account "%(username)s" has been destroyed.') % {'username': user.username})
return redirect('users')
开发者ID:0x1330,项目名称:Misago,代码行数:31,代码来源:destroyuser.py
示例6: crop
def crop(request, upload=False):
if upload and (not request.user.avatar_temp or not 'upload' in settings.avatars_types):
return error404(request)
if not upload and request.user.avatar_type != 'upload':
messages.error(request, _("Crop Avatar option is avaiable only when you use uploaded image as your avatar."), 'usercp_avatar')
return redirect(reverse('usercp_avatar'))
message = request.messages.get_message('usercp_avatar')
if request.method == 'POST':
if request.csrf.request_secure(request):
try:
image_path = settings.MEDIA_ROOT + 'avatars/'
if upload:
source = Image.open(image_path + request.user.avatar_temp)
else:
source = Image.open(image_path + request.user.avatar_original)
width, height = source.size
aspect = float(width) / float(request.POST['crop_b'])
crop_x = int(aspect * float(request.POST['crop_x']))
crop_y = int(aspect * float(request.POST['crop_y']))
crop_w = int(aspect * float(request.POST['crop_w']))
crop = source.crop((crop_x, crop_y, crop_x + crop_w, crop_y + crop_w))
if upload:
image_name, image_extension = path(request.user.avatar_temp).splitext()
else:
image_name, image_extension = path(request.user.avatar_original).splitext()
image_name = '%s_%s%s' % (request.user.pk, random_string(8), image_extension)
resizeimage(crop, settings.AVATAR_SIZES[0], image_path + image_name, info=source.info, format=source.format)
for size in settings.AVATAR_SIZES[1:]:
resizeimage(crop, size, image_path + str(size) + '_' + image_name, info=source.info, format=source.format)
request.user.delete_avatar_image()
if upload:
request.user.delete_avatar_original()
request.user.avatar_type = 'upload'
request.user.avatar_original = '%s_org_%s%s' % (request.user.pk, random_string(8), image_extension)
source.save(image_path + request.user.avatar_original)
request.user.delete_avatar_temp()
request.user.avatar_image = image_name
request.user.avatar_crop = [str(float(request.POST[x])) for x in ('crop_x', 'crop_y', 'crop_w')]
request.user.save(force_update=True)
messages.success(request, _("Your avatar has been cropped."), 'usercp_avatar')
return redirect(reverse('usercp_avatar'))
except Exception:
message = Message(_("Form contains errors."), messages.ERROR)
else:
message = Message(_("Request authorisation is invalid."), messages.ERROR)
return render_to_response('usercp/avatar_crop.html',
context_instance=RequestContext(request, {
'message': message,
'after_upload': upload,
'avatar_size': settings.AVATAR_SIZES[0],
'avatar_crop': request.user.avatar_crop if not upload else None,
'source': 'avatars/%s' % (request.user.avatar_temp if upload else request.user.avatar_original),
'tab': 'avatar'}));
开发者ID:0x1330,项目名称:Misago,代码行数:60,代码来源:views.py
示例7: activate
def activate(request, token):
new_credentials = request.session.get("new_credentials")
if not new_credentials or new_credentials["token"] != token:
return error404(request)
if new_credentials["new_email"]:
request.user.set_email(new_credentials["new_email"])
if new_credentials["new_password"]:
request.user.set_password(new_credentials["new_password"])
try:
request.user.full_clean()
request.user.save(force_update=True)
request.user.sessions.exclude(id=request.session.id).delete()
request.user.signin_tokens.all().delete()
messages.success(
request,
_("%(username)s, your Sign-In credentials have been changed.") % {"username": request.user.username},
"security",
)
request.session.sign_out(request)
del request.session["new_credentials"]
return redirect(reverse("sign_in"))
except ValidationError:
messages.error(
request, _("Your new credentials have been invalidated. Please try again."), "usercp_credentials"
)
return redirect(reverse("usercp_credentials"))
开发者ID:hopecream,项目名称:Misago,代码行数:28,代码来源:views.py
示例8: update_watcher
def update_watcher(self, request, watcher):
watcher.email = False
messages.success(
request,
_("You will no longer receive e-mails with notifications when somebody replies to this thread."),
"threads",
)
开发者ID:pzduniak,项目名称:Misago,代码行数:7,代码来源:jumps.py
示例9: view
def view(request):
self.fetch_poll()
if 'show_results' in request.POST:
if not self.poll.user_votes:
self.poll.make_empty_vote(request)
self.poll.save()
return self.poll_redirect()
if 'show_options' in request.POST:
if self.poll.user_votes and not self.poll.user_votes[0].option_id:
self.poll.retract_votes(self.poll.user_votes)
self.poll.save()
return self.poll_redirect()
if 'change_vote' in request.POST:
if self.poll.user_votes and self.poll.user_votes[0].option_id and self.poll.vote_changing:
self.poll.retract_votes(self.poll.user_votes)
self.poll.save()
return self.poll_redirect()
if self.poll.user_votes and self.poll.user_votes[0].option_id and not self.poll.vote_changing:
messages.error(_("Changing vote in this poll is not allowed."), 'poll_%s' % self.poll.pk)
return self.poll_redirect()
form = PollVoteForm(self.request.POST, request=self.request, poll=self.poll)
if form.is_valid():
if self.poll.user_votes:
self.poll.retract_votes(self.poll.user_votes)
self.poll.make_vote(self.request, form.cleaned_data['options'])
self.poll.save()
messages.success(self.request, _("Your vote has been cast."), 'poll_%s' % self.poll.pk)
elif 'options' in form.errors:
messages.error(self.request, form.errors['options'][0], 'poll_%s' % self.poll.pk)
return self.poll_redirect()
开发者ID:0x1330,项目名称:Misago,代码行数:35,代码来源:jumps.py
示例10: make_jump
def make_jump(self):
username = slugify(self.request.POST.get('username', '').strip())
if not username:
messages.error(self.request, _('You have to enter name of user you want to invite to thread.'), 'threads')
return self.retreat_redirect()
try:
user = User.objects.get(username_slug=username)
acl = user.acl()
if user in self.thread.participants.all():
if user.pk == self.request.user.pk:
messages.error(self.request, _('You cannot add yourself to this thread.'), 'threads')
else:
messages.info(self.request, _('%(user)s is already participating in this thread.') % {'user': user.username}, 'threads')
elif not acl.private_threads.can_participate():
messages.info(self.request, _('%(user)s cannot participate in private threads.') % {'user': user.username}, 'threads')
elif (not self.request.acl.private_threads.can_invite_ignoring() and
not user.allow_pd_invite(self.request.user)):
messages.info(self.request, _('%(user)s restricts who can invite him to private threads.') % {'user': user.username}, 'threads')
else:
self.thread.participants.add(user)
user.sync_pds = True
user.save(force_update=True)
user.email_user(self.request, 'private_thread_invite', _("You've been invited to private thread \"%(thread)s\" by %(user)s") % {'thread': self.thread.name, 'user': self.request.user.username}, {'author': self.request.user, 'thread': self.thread})
self.thread.set_checkpoint(self.request, 'invited', user)
messages.success(self.request, _('%(user)s has been added to this thread.') % {'user': user.username}, 'threads')
except User.DoesNotExist:
messages.error(self.request, _('User with requested username could not be found.'), 'threads')
return self.retreat_redirect()
开发者ID:FaceHunter,项目名称:Misago,代码行数:28,代码来源:jumps.py
示例11: options
def options(request):
message = request.messages.get_message('usercp_options')
if request.method == 'POST':
form = UserForumOptionsForm(request.POST, request=request)
if form.is_valid():
request.user.hide_activity = form.cleaned_data['hide_activity']
request.user.allow_pds = form.cleaned_data['allow_pds']
request.user.receive_newsletters = form.cleaned_data['newsletters']
request.user.timezone = form.cleaned_data['timezone']
request.user.subscribe_start = form.cleaned_data['subscribe_start']
request.user.subscribe_reply = form.cleaned_data['subscribe_reply']
request.user.save(force_update=True)
messages.success(request, _("Forum options have been changed."), 'usercp_options')
return redirect(reverse('usercp'))
message = Message(form.non_field_errors()[0], messages.ERROR)
else:
form = UserForumOptionsForm(request=request, initial={
'newsletters': request.user.receive_newsletters,
'hide_activity': request.user.hide_activity,
'allow_pds': request.user.allow_pds,
'timezone': request.user.timezone,
'subscribe_start': request.user.subscribe_start,
'subscribe_reply': request.user.subscribe_reply,
})
return render_to_response('usercp/options.html',
context_instance=RequestContext(request, {
'message': message,
'tab': 'options',
'form': form}));
开发者ID:0x1330,项目名称:Misago,代码行数:30,代码来源:views.py
示例12: settings
def settings(request, group_id=None, group_slug=None):
# Load groups and find selected group
settings_groups = SettingsGroup.objects.all().order_by('key')
if not group_id:
active_group = settings_groups[0]
group_id = active_group.pk
else:
group_id = int(group_id)
for group in settings_groups:
if group.pk == group_id:
active_group = group
break
else:
return error404(request, _('Requested settings group could not be found.'))
# Load selected group settings and turn them into form
group_settings = Setting.objects.filter(group=active_group).order_by('position')
last_fieldset = (None, [])
group_form = {'fieldsets': []}
for setting in group_settings:
# New field subgroup?
if setting.separator and last_fieldset[0] != setting.separator:
if last_fieldset[0]:
group_form['fieldsets'].append(last_fieldset)
last_fieldset = (_(setting.separator), [])
last_fieldset[1].append(setting.pk)
group_form[setting.pk] = setting.get_field()
group_form['fieldsets'].append(last_fieldset)
SettingsGroupForm = type('SettingsGroupForm', (Form,), group_form)
#Submit form
message = messages.get_message(request, 'admin_settings')
if request.method == 'POST':
form = SettingsGroupForm(request.POST, request=request)
if form.is_valid():
for setting in form.cleaned_data.keys():
misago_settings[setting] = form.cleaned_data[setting]
cache.delete('settings')
messages.success(request, _('Configuration has been changed.'), 'admin_settings')
return redirect(reverse('admin_settings', kwargs={
'group_id': active_group.pk,
'group_slug': active_group.key,
}))
else:
message = Message(form.non_field_errors()[0], messages.ERROR)
else:
form = SettingsGroupForm(request=request)
# Display settings group form
return render_to_response('settings/settings.html',
{
'message': message,
'groups': settings_groups,
'active_group': active_group,
'search_form': SearchForm(request=request),
'form': FormIterator(form),
'raw_form': form,
},
context_instance=RequestContext(request));
开发者ID:0x1330,项目名称:Misago,代码行数:59,代码来源:views.py
示例13: update_watcher
def update_watcher(self, request, watcher):
watcher.deleted = True
if watcher.pk:
watcher.delete()
if watcher.email:
messages.success(request, _('This thread has been removed from your watched threads list. You will no longer receive e-mails with notifications when somebody replies to it.'), 'threads')
else:
messages.success(request, _('This thread has been removed from your watched threads list.'), 'threads')
开发者ID:0x1330,项目名称:Misago,代码行数:8,代码来源:jumps.py
示例14: view
def view(request):
ignored_exclusions = request.session.get("unignore_threads", [])
ignored_exclusions.append(self.thread.pk)
request.session["unignore_threads"] = ignored_exclusions
messages.success(
request, _("Replies made to this thread by members on your ignore list have been revealed."), "threads"
)
return redirect(reverse(self.type_prefix, kwargs={"thread": self.thread.pk, "slug": self.thread.slug}))
开发者ID:pzduniak,项目名称:Misago,代码行数:8,代码来源:jumps.py
示例15: __call__
def __call__(self, request, target=None, slug=None):
self.request = request
# Fetch target
model = None
if target:
model = self.get_and_validate_target(target)
self.original_name = self.get_target_name(model)
if not model:
return redirect(self.get_fallback_link())
original_model = model
# Set filter
users = model.make_queryset()
total_users = users.count()
if not total_users:
messages.error(request, _('Policy "%(name)s" does not apply to any users.') % {'name': model.name}, self.admin.id)
return redirect(reverse('admin_prune_users'))
message = None
if request.method == 'POST':
deleted = 0
if request.csrf.request_secure(request):
for user in users.iterator():
if user.is_protected():
messages.info(request, _('User "%(name)s" is protected and was not deleted.') % {'name': user.username}, self.admin.id)
else:
user.delete()
deleted += 1
if deleted:
messages.success(request, ungettext(
'One user has been deleted.',
'%(deleted)d users have been deleted.',
deleted
) % {'deleted': deleted}, self.admin.id)
User.objects.resync_monitor()
else:
messages.info(request, _("No users have been deleted."), self.admin.id)
return redirect(reverse('admin_prune_users'))
else:
message = Message(_("Request authorization is invalid. Please resubmit your form."), messages.ERROR)
return render_to_response(self.get_template(),
{
'admin': self.admin,
'action': self,
'request': request,
'link': self.get_link(model),
'fallback': self.get_fallback_link(),
'messages': messages.get_messages(request, self.admin.id),
'message': message,
'tabbed': self.tabbed,
'total_users': total_users,
'target': self.get_target_name(original_model),
'target_model': original_model,
},
context_instance=RequestContext(request));
开发者ID:0x1330,项目名称:Misago,代码行数:58,代码来源:views.py
示例16: form
def form(request):
"""
Allow admins to generate fancy statistic graphs for different models
"""
models_map = {}
for model in models.get_models():
try:
getattr(model.objects, "filter_stats")
statistics_providers.append((str(model.__name__).lower(), model.statistics_name))
models_map[str(model.__name__).lower()] = model
except AttributeError:
pass
if not statistics_providers:
"""
Something went FUBAR - Misago ships with some stats providers out of box
If those providers cant be found, this means Misago filesystem is corrupted
"""
return render_to_response("stats/not_available.html", context_instance=RequestContext(request))
message = None
if request.method == "POST":
form = GenerateStatisticsForm(request.POST, provider_choices=statistics_providers, request=request)
if form.is_valid():
date_start = form.cleaned_data["date_start"]
date_end = form.cleaned_data["date_end"]
if date_start > date_end:
# Reverse dates if start is after end
date_temp = date_end
date_end = date_start
date_start = date_temp
# Assert that dates are correct
if date_end == date_start:
message = Message(_("Start and end date are same"), messages.ERROR)
elif check_dates(date_start, date_end, form.cleaned_data["stats_precision"]):
message = check_dates(date_start, date_end, form.cleaned_data["stats_precision"])
else:
messages.success(request, _("Statistical report has been created."), "admin_stats")
return redirect(
reverse(
"admin_stats_graph",
kwargs={
"model": form.cleaned_data["provider_model"],
"date_start": date_start.strftime("%Y-%m-%d"),
"date_end": date_end.strftime("%Y-%m-%d"),
"precision": form.cleaned_data["stats_precision"],
},
)
)
else:
message = Message(form.non_field_errors()[0], messages.ERROR)
else:
form = GenerateStatisticsForm(provider_choices=statistics_providers, request=request)
return render_to_response(
"stats/form.html", {"form": form, "message": message}, context_instance=RequestContext(request)
)
开发者ID:pzduniak,项目名称:Misago,代码行数:57,代码来源:views.py
示例17: form
def form(request):
"""
Allow admins to generate fancy statistic graphs for different models
"""
statistics_providers = []
models_map = {}
for model in models.get_models():
try:
getattr(model.objects, 'filter_stats')
statistics_providers.append((str(model.__name__).lower(), model.statistics_name))
models_map[str(model.__name__).lower()] = model
except AttributeError:
pass
if not statistics_providers:
"""
Something went FUBAR - Misago ships with some stats providers out of box
If those providers cant be found, this means Misago filesystem is corrupted
"""
return render_to_response('stats/not_available.html',
context_instance=RequestContext(request));
message = None
if request.method == 'POST':
form = GenerateStatisticsForm(request.POST, provider_choices=statistics_providers, request=request)
if form.is_valid():
date_start = form.cleaned_data['date_start']
date_end = form.cleaned_data['date_end']
if date_start > date_end:
# Reverse dates if start is after end
date_temp = date_end
date_end = date_start
date_start = date_temp
# Assert that dates are correct
if date_end == date_start:
message = Message(_('Start and end date are same'), messages.ERROR)
elif check_dates(date_start, date_end, form.cleaned_data['stats_precision']):
message = check_dates(date_start, date_end, form.cleaned_data['stats_precision'])
else:
messages.success(request, _('Statistical report has been created.'), 'admin_stats')
return redirect(reverse('admin_stats_graph', kwargs={
'model': form.cleaned_data['provider_model'],
'date_start': date_start.strftime('%Y-%m-%d'),
'date_end': date_end.strftime('%Y-%m-%d'),
'precision': form.cleaned_data['stats_precision']
}))
else:
message = Message(form.non_field_errors()[0], messages.ERROR)
else:
form = GenerateStatisticsForm(provider_choices=statistics_providers, request=request)
return render_to_response('stats/form.html',
{
'form': form,
'message': message,
},
context_instance=RequestContext(request));
开发者ID:0x1330,项目名称:Misago,代码行数:57,代码来源:views.py
示例18: delete_warning
def delete_warning(request, user, warning):
request.acl.warnings.allow_delete_warning()
if user.is_warning_active(warning):
alerts.your_warn_has_been_canceled(request.user, user)
user.decrease_warning_level()
warning.delete()
messages.success(request, _("Selected warning has been deleted."))
开发者ID:0x1330,项目名称:Misago,代码行数:9,代码来源:views.py
示例19: action_accept
def action_accept(self, ids):
if self._action_accept(ids):
messages.success(
self.request,
_("Selected threads have been marked as reviewed and made visible to other members."),
"threads",
)
else:
messages.info(self.request, _("No threads were marked as reviewed."), "threads")
开发者ID:hopecream,项目名称:Misago,代码行数:9,代码来源:moderation.py
示例20: post_action_protect
def post_action_protect(self, ids):
protected = 0
for post in self.posts:
if post.pk in ids and not post.protected:
protected += 1
if protected:
self.thread.post_set.filter(id__in=ids).update(protected=True)
messages.success(self.request, _("Selected posts have been protected from edition."), "threads")
else:
messages.info(self.request, _("No posts were protected."), "threads")
开发者ID:pzduniak,项目名称:Misago,代码行数:10,代码来源:posts.py
注:本文中的misago.messages.success函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论