本文整理汇总了Python中messages.Messages.add方法的典型用法代码示例。如果您正苦于以下问题:Python Messages.add方法的具体用法?Python Messages.add怎么用?Python Messages.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messages.Messages
的用法示例。
在下文中一共展示了Messages.add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def create(self):
"""Handles the POST data for creating a group.
Form Variables:
name: the name of the new group
public: true if the group should be joinable by the public
"""
if auth.logged_in():
name = self.request.get('name')
public = self.request.get('public') == 'public'
owner = auth.current_user()
if Group.exists(name):
Messages.add('A group with that name already exists')
return self.redirect('/groups/signup')
Group(name=name,
public=public,
owner=owner,
members=[owner]).put()
return self.redirect('/groups')
else:
Messages.add('You must be logged in to create a group')
return self.redirect('/groups/signup')
示例2: delete
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def delete(self, key):
if auth.user_is_admin():
Project.get(key).delete()
else:
Messages.add('Only and administrator may delete projects. This ' +
'incident has been logged.')
return self.redirect('/projects')
示例3: signup
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def signup(self):
user = auth.User(auth.current_user())
if user.in_group():
Messages.add('You are already in a group')
return self.redirect('/groups')
else:
return self.render('groups_signup')
示例4: update_group
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def update_group(self, key):
if not auth.logged_in():
return self.redirect('/groups')
user = auth.current_user()
group = Group.get(key)
if group.owner.user_id() != user.user_id() and not auth.user_is_admin():
Messages.add('Only the owner of the group owner may modify it')
return self.redirect('/groups')
name = self.request.get('name')
public = self.request.get('public') == 'public'
abandon = self.request.get('abandon-project')
sub_text = self.request.get('submission-text')
sub_url = self.request.get('submission-url')
remove_submission = self.request.get_all('remove-submission')
remove = self.request.get_all('remove')
owner = self.request.get('owner')
delete = self.request.get('delete')
if delete:
group.delete()
return self.redirect('/groups')
group.name = name
group.public = public
if abandon:
group.project = None
if sub_text and sub_url:
Submission(text=sub_text, url=sub_url, group=group).put()
for sub in Submission.get(remove_submission):
sub.delete()
pending = list(group.pending_users)
for user in pending:
approve = self.request.get("approve-%s" % user)
if approve == "approve":
group.members.append(user)
group.pending_users.remove(user)
elif approve == "refuse":
group.pending_users.remove(user)
group.owner = auth.user_from_email(owner)
for user in remove:
if auth.user_from_email(user) == group.owner:
Messages.add('Cannot remove the group owner')
return self.redirect('/groups/%s/edit' % key)
else:
group.members.remove(auth.user_from_email(user))
group.put()
return self.redirect('/groups/%s' % key)
示例5: edit
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def edit(self, key):
if not auth.logged_in():
return self.redirect('/groups')
user = auth.current_user()
group = Group.get(key)
if group.owner.user_id() == user.user_id() or auth.user_is_admin():
return self.render('groups_edit', { 'group': group })
else:
Messages.add('Only the owner of this group may edit it')
return self.redirect('/groups/%s' % key)
示例6: leave
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def leave(self, key):
group = Group.get(key)
user = auth.User(auth.current_user())
if user.group != group:
Messages.add('You cannot leave a group you are not in')
return self.redirect('/groups/%s' % key)
group.members.remove(user.gae_user)
group.put()
return self.redirect('/groups')
示例7: claim
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def claim(self, key):
user = auth.User(auth.current_user())
group = user.group
if group.owner.user_id() == auth.current_user().user_id():
project = Project.get(key)
group.project = project
group.put()
return self.redirect('/groups/%s' % group.key())
else:
Messages.add('You are not the owner of your group. Only the ' +
'owner of the group may select a project.')
return self.redirect('/projects')
示例8: approve
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def approve(self, key):
if auth.user_is_admin():
idea = Idea.get(key)
Project(name=idea.name,
description=idea.description,
author=idea.author,
post_time=idea.post_time).put()
idea.delete()
return self.redirect('/projects')
else:
Messages.add('Only and administrator may approve submitted ' +
'ideas. This incident has been logged.')
return self.redirect('/ideas')
示例9: join
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def join(self, key):
group = Group.get(key)
user = auth.User(auth.current_user())
if user.in_group():
Messages.add('You are already in a group')
return self.redirect('/groups/%s' % key)
if user.pending_join():
Messages.add('You have already applied to join a group')
return self.redirect('/groups/%s' % key)
if group.public:
group.members.append(auth.current_user())
Messages.add('You have joined the group')
else:
group.pending_users.append(auth.current_user())
Messages.add('You have requested to join the group')
group.put()
return self.redirect('/groups/%s' % key)
示例10: update_group
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
def update_group(self, key):
"""Updates a group with information from the moderation form.
Form Variables:
name: the name of the group
public: true if the group should be joinable by the
public
abandon-project: true if the group moderator wants to abandon the
current project
submission-text: the text to be displayed for the new submission
submission-url: the URL of the new submission
remove-submission: a list of submissions to be removed
remove: a list of users to be removed from the group
owner: the owner of the group
delete: true if the group moderator wants to disband the
group
"""
if not auth.logged_in():
return self.redirect('/groups')
user = auth.current_user()
group = Group.get(key)
if (group.owner.user_id() != user.user_id() and
not auth.user_is_admin()):
Messages.add('Only the owner of the group owner may modify it')
return self.redirect('/groups')
name = self.request.get('name')
public = self.request.get('public') == 'public'
abandon = self.request.get('abandon-project')
sub_text = self.request.get('submission-text')
sub_url = self.request.get('submission-url')
remove_submission = self.request.get_all('remove-submission')
remove = self.request.get_all('remove')
owner = self.request.get('owner')
delete = self.request.get('delete')
if delete:
group.delete()
return self.redirect('/groups')
group.name = name
group.public = public
if abandon:
group.project = None
if sub_text and sub_url:
Submission(text=sub_text, url=sub_url, group=group).put()
for sub in Submission.get(remove_submission):
sub.delete()
pending = list(group.pending_users)
for user in pending:
approve = self.request.get("approve-%s" % user)
if approve == "approve":
group.members.append(user)
group.pending_users.remove(user)
elif approve == "refuse":
group.pending_users.remove(user)
group.owner = auth.user_from_email(owner)
for user in remove:
if auth.user_from_email(user) == group.owner:
Messages.add('Cannot remove the group owner')
return self.redirect('/groups/%s/edit' % key)
else:
group.members.remove(auth.user_from_email(user))
group.put()
return self.redirect('/groups/%s' % key)
示例11: Window
# 需要导入模块: from messages import Messages [as 别名]
# 或者: from messages.Messages import add [as 别名]
class Window(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title)
# Splitters and Panels
self.controls_map_splitter = wx.SplitterWindow(self)
self.controls_map_splitter.SetMinimumPaneSize(300)
controls_panel = wx.Panel(self.controls_map_splitter)
map_panel = wx.Panel(self.controls_map_splitter)
self.graphs_messages_splitter = wx.SplitterWindow(controls_panel)
self.graphs_messages_splitter.SetMinimumPaneSize(50)
graphs_panel = wx.Panel(self.graphs_messages_splitter)
messages_panel = wx.Panel(self.graphs_messages_splitter)
# World graphic
self._graphics = worldmap.WorldMap(map_panel)
self.graphics_sizer = wx.BoxSizer(wx.VERTICAL)
self.graphics_sizer.Add(self._graphics, 1, wx.EXPAND)
map_panel.SetSizerAndFit(self.graphics_sizer)
# Controls panel
self.controls = Controls(controls_panel, (300, 250), self)
# Info panel
self.info = Info(controls_panel, (300, 250))
# Graph canvas
self.graphs = graphs.Graphs(graphs_panel, (300, 300))
# Messages panel
self.messages = Messages(messages_panel, (600, 200))
self.interface_sizer = wx.BoxSizer(wx.VERTICAL)
self.controls_info_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.controls_info_sizer.Add(self.info, 0, wx.EXPAND)
self.controls_info_sizer.Add((20, -1), proportion=0) # Padding
self.controls_info_sizer.Add(self.controls, 1, wx.EXPAND)
self.messages_sizer = wx.BoxSizer(wx.VERTICAL)
self.messages_sizer.Add(self.messages, 1, wx.EXPAND)
messages_panel.SetSizerAndFit(self.messages_sizer)
self.graphs_sizer = wx.BoxSizer(wx.VERTICAL)
self.graphs_sizer.Add(self.graphs, 1, wx.EXPAND)
graphs_panel.SetSizerAndFit(self.graphs_sizer)
self.interface_sizer.Add(self.controls_info_sizer, 0, wx.EXPAND)
self.interface_sizer.Add(self.graphs_messages_splitter, 1, wx.EXPAND)
controls_panel.SetSizerAndFit(self.interface_sizer)
self.graphs_messages_splitter.SplitHorizontally(
messages_panel,
graphs_panel
)
self.controls_map_splitter.SplitVertically(controls_panel, map_panel)
# Set up event handler for any worker thread results
EVT_RESULT(self, self.OnResult)
EVT_STOP(self, self.OnStop)
# Set up close event so timer is properly stopped
wx.EVT_CLOSE(self, self.OnClose)
self.reset_gui()
self.Show()
def reset_gui(self):
self.controls.reset_buttons()
self.messages.clear()
self.graphs.reset_data()
# Event Methods
def OnStart(self, event):
self.controls.set_buttons_ready()
self._simulation = simulation.Simulation()
self._simulation.setup_config(self.controls.get_config_filename())
self.simulation_info = self._simulation.initialize()
if not self.simulation_info.interface_config.print_messages:
self.messages.deactivate()
self._graphics.num_max_complaints = \
self.simulation_info.num_max_complaints
self.rounds = 0
self.steps = 0
self.next_phase = "COASTPLAN"
self.prev_phase = None
self.worker = None
#.........这里部分代码省略.........