def process_admin_actions(self, request, vote): action = request.getvalue('voteraction', '') if action == 'changetype': vote.type = request.getvalue('type', '') vote_classes[vote.type].initialize_vote(vote) vote.save() elif action == 'newvoteitem': voteitems = vote.search1(node='VoteItems') newitem = datagate.create_item(parentid=voteitems.id, creatorid=request.session.user.id) newitem.text = request.getvalue('text', '') newitem.save() elif action == 'deletevoteitem': datagate.del_item(request.getvalue('votechildid', '')) elif action == 'pasteclipboard': # get the data from the session object try: itemids = request.session.clipboarddata except AttributeError: # no clipboard data available return # paste to the current root id events = [] vote = datagate.get_item(request.getvalue('itemid', '')) parent = vote.search1(node='VoteItems') for itemid in itemids: if datagate.get_item(itemid): newitem = datagate.copy_deep(itemid, parent.id)
def delgroup_action(self, request): game = datagate.get_item(request.getvalue('itemid')) turns = game.search1(name='turns') groupid = request.getvalue('groupid') group = datagate.get_item(groupid) # go through the assets for this group and delete any assets who were in this group for turn in turns: for asset in turn.search1(name='assetmoves'): if asset.teamid == groupid: asset.delete() datagate.del_item(request.getvalue('groupid', '')) game = datagate.get_item(request.getvalue('itemid')) chats = game.search1(name='chats') group_name = request.getvalue('groupname','') group_chat = chats.search1(name=group_name) datagate.del_item(group_chat.id)
def groupusers_action(self, request): game = datagate.get_item(request.getvalue('itemid')) teams = game.search1(name='groups') chats = game.search1(name='chats') board = game.search1(name='board') submit = request.getvalue('submit', '') group = teams.get_child(request.getvalue('groupid', '')) if submit == '->': group_users = [ child.user_id for child in group.get_child_items() ] for user_id in request.getlist('allusers'): if not user_id in group_users: child = datagate.create_item(creatorid=request.session.user.id, parentid=group.id) child.user_id = user_id child.save() elif submit == '<-': for user_id in request.getlist('members'): for child in group.get_child_items(): if child.user_id == user_id: datagate.del_item(child.id) break
def process_admin_actions(self, request): '''Process all item actions''' meeting = datagate.get_item(request.getvalue('global_meetingid', '')) action = request.getvalue('_mhaction', '') if action == 'copyitem': meeting = datagate.copy_deep(request.getvalue('_copyitemid', ''), Directory.meetings_item.id) meeting.name = request.getvalue('_itemname', '') meeting.save() return meeting #elif action == 'publish': #handled by Ask elif action == 'results': meeting.status = 2 elif action == 'import': try: importfile = request.form['subaction'] gz = gzip.GzipFile(importfile.filename, 'r', fileobj=importfile.file) doc = xml.dom.minidom.parse(gz) except IOError: raise IOError, 'An error occurred while importing the file. Are you sure it is a gzipped XML document (exported from GroupMind)?' return Directory.import_meeting(doc, request.session.user.id) activities_item = meeting.search1(name='activities') groups_item = meeting.search1(name='groups') if action == 'editname': itemname = request.getvalue('activityname', '') if itemname != '': child = activities_item.get_child(request.getvalue('activityid')) child.name = itemname child.save() elif action == 'addactivity': # create the activity name = request.getvalue('name', '') if name != '': activity = datagate.create_item(creatorid=request.session.user.id, parentid=activities_item.id) activity.name = name activity.previousid = request.getvalue('previousid', '') activity.view = request.getvalue('viewtype', '') activity.save() # allow the activity view to initialize itself BaseView.views[activity.view.lower()].initialize_activity(request, activity) elif action == 'delactivity': datagate.del_item(request.getvalue('activityid', '')) elif action == 'moveactivity': activity = datagate.get_item(request.getvalue('activityid')) parent = activity.get_parent() parent.remove_child(activity) parent.insert_child(activity, request.getvalue('previousid')) parent.save() elif action == 'addgroup': name = request.getvalue('name', '') if name != '': group = datagate.create_item(creatorid=request.session.user.id, parentid=groups_item.id) group.name = name group.save() elif action == 'delgroup': datagate.del_item(request.getvalue('groupid', '')) elif action == 'groupusers': fromGroup = request.getvalue('fromGroup', '') toGroup = request.getvalue('toGroup', '') users = request.getvalue('users', '').split() if not fromGroup == "unassigned_list": for c in datagate.get_child_items(fromGroup): for u in users: if c.user_id == u: datagate.get_item(fromGroup).remove_child(c) if not toGroup == "unassigned_list": for u in users: child = datagate.create_item(creatorid=request.session.user.id, parentid=toGroup) child.user_id = u child.save() elif action == 'addset': groupid = request.getvalue('groupid', '') group = datagate.get_item(groupid) submit = request.getvalue('switchSet', '') if submit == 'released': meeting.status = 1 creator = request.session.user activities_item = meeting.search1(name='activities') root = activities_item.search1(name="Question Editor") questions = root.search1(name="questions") groupMapping = root.search1(name="groupMapping") d = {} #dictionary -- for binding dynamic variable names to values for g in groupMapping: listName = (str(g.name) + "IDlist").replace(' ', '') #replace -- removes spaces d[listName] = [] sets = root.search1(name="sets") d2 = {} #dictionary -- for binding dynamic variable names to values for s in sets: listName2 = (str(s.name) + "IDlist").replace(' ', '') #replace -- removes spaces d2[listName2] = [] for q in questions: if not q.delete: userGroups = q.users for u in userGroups: for g in groupMapping: if u == g.name: listName = (str(g.name) + "IDlist").replace(' ', '') (d[listName]).append(q.id) allSets = q.search1(name="sets") for t in allSets.get_child_items(self): for s in sets: if s.name == t.name: listName2 = (str(s.name) + "IDlist").replace(' ', '') (d2[listName2]).append(q.id) for g in groupMapping: children = g.get_child_items(self) if not children: p = datagate.create_item(creatorid=creator.id, parentid=g.id) p.name = 'percent' p.percent = 0 p.save() ques = datagate.create_item(creatorid=creator.id, parentid=g.id) ques.name = 'quesId' else: ques = g.search1(name='quesId') listName = (str(g.name) + "IDlist").replace(' ', '') ques.quesId = d[listName] ques.save() for s in sets: childs = s.get_child_items(self) if not childs: questions = datagate.create_item(creatorid=creator.id, parentid=s.id) questions.name = "quesId" else: questions = s.search1(name='quesId') listName2 = (str(s.name) + "IDlist").replace(' ', '') questions.quesId = d2[listName2] questions.save() setsid = request.getvalue('setsid', '') sets = datagate.get_item(setsid) setList = [] for item in sets: cbname = item.name + "_cb" cb = request.getvalue(cbname, '') if cb == "on": setList.append(item.name) if setList == []: group.sets = '' else: group.sets = setList else: group.sets = '' group.save() # finally, return the meeting (since we might have created it here) return meeting
def delactivity_action(self, request): datagate.del_item(request.getvalue('activityid', ''))
def delete_comment_action(self, request): '''Responds to a delete event from the browser''' datagate.del_item(request.getvalue('itemid', '')) return [ 'processDelete("%s")' % request.getvalue('itemid', '') ]
def del_item(self, request): '''Deletes an item''' datagate.del_item(request.getvalue('id', 'Empty'))
def process_admin_actions(self, request): '''Process all item actions''' meeting = datagate.get_item(request.getvalue('global_meetingid', '')) action = request.getvalue('_mhaction', '') #log.info("process_admin_actions called with action = "+action) if action == 'copyitem': meeting = datagate.copy_deep(request.getvalue('_copyitemid', ''), Directory.meetings_item.id) meeting.name = request.getvalue('_itemname', '') meeting.save() return meeting #elif action == 'publish': #handled by Ask elif action == 'results': meeting.status = 2 elif action == 'import': try: importfile = request.form['subaction'] gz = gzip.GzipFile(importfile.filename, 'r', fileobj=importfile.file) doc = xml.dom.minidom.parse(gz) except IOError: raise IOError, 'An error occurred while importing the file. Are you sure it is a gzipped XML document (exported from GroupMind)?' return Directory.import_meeting(doc, request.session.user.id) activities_item = meeting.search1(name='activities') groups_item = meeting.search1(name='groups') if action == 'editname': itemname = request.getvalue('activityname', '') if itemname != '': child = activities_item.get_child(request.getvalue('activityid')) child.name = itemname child.save() elif action == 'addactivity': # create the activity name = request.getvalue('name', '') if name != '': activity = datagate.create_item(creatorid=request.session.user.id, parentid=activities_item.id) activity.name = name activity.previousid = request.getvalue('previousid', '') activity.view = request.getvalue('viewtype', '') activity.save() # allow the activity view to initialize itself BaseView.views[activity.view.lower()].initialize_activity(request, activity) elif action == 'delactivity': datagate.del_item(request.getvalue('activityid', '')) elif action == 'moveactivity': activity = datagate.get_item(request.getvalue('activityid')) parent = activity.get_parent() parent.remove_child(activity) parent.insert_child(activity, request.getvalue('previousid')) parent.save() elif action == 'addgroup': name = request.getvalue('name', '') if name != '': group = datagate.create_item(creatorid=request.session.user.id, parentid=groups_item.id) group.name = name group.save() elif action == 'delgroup': datagate.del_item(request.getvalue('groupid', '')) elif action == 'groupusers': #fromGroup = request.getvalue('fromGroup', '') toGroup = request.getvalue('toGroup', '') movingUsers = request.getvalue('users', '').split() groups = meeting.search1(name='groups') for group in groups: for user in group: if user.user_id in movingUsers: #log.info("match found: removing "+user.user_id+" from "+group.name) group.remove_child(user) ''' # this assumes that there's only one group the users are coming from, which is not guaranteed if not fromGroup == "unassigned_list": for c in datagate.get_child_items(fromGroup): for u in users: if c.user_id == u: datagate.get_item(fromGroup).remove_child(c) ''' if not toGroup == "unassigned_list": toGroupUsers = datagate.get_item(toGroup) toGroupUserIds = [user.user_id for user in toGroupUsers] for u in movingUsers: if u not in toGroupUserIds: #but actually write this line #wait, why is this comment still here? did my pseudocode accidentally work? child = datagate.create_item(creatorid=request.session.user.id, parentid=toGroup) child.user_id = u child.save() elif action == 'openQuestions' or action == 'closeQuestions': groupid = request.getvalue('groupid', '') group = datagate.get_item(groupid) #submit = request.getvalue('switchSets_'+group.name, '') if action == 'openQuestions': for user in group: user_data = datagate.get_item(user.user_id) user_data.answeredQuestions = [] #whenever a set is released/closed, wipe the list of backtrackable-questions user_data.backtrack = 0 user_data.initialize = True user_data.save() meeting.status = 1 creator = request.session.user activities_item = meeting.search1(name='activities') root = activities_item.search1(name="Question Editor") questions = root.search1(name="questions") groupMapping = root.search1(name="groupMapping") d = {} #dictionary -- for binding dynamic variable names to values for g in groupMapping: listName = (str(g.name) + "IDlist").replace(' ', '') #replace -- removes spaces d[listName] = [] sets = root.search1(name="sets") d2 = {} #dictionary -- for binding dynamic variable names to values for s in sets: listName2 = (str(s.name) + "IDlist").replace(' ', '') #replace -- removes spaces d2[listName2] = [] for q in questions: if not q.delete: userGroups = q.users for u in userGroups: for g in groupMapping: if u == g.name: listName = (str(g.name) + "IDlist").replace(' ', '') (d[listName]).append(q.id) allSets = q.search1(name="sets") for t in allSets.get_child_items(self): for s in sets: if s.name == t.name: listName2 = (str(s.name) + "IDlist").replace(' ', '') (d2[listName2]).append(q.id) for g in groupMapping: children = g.get_child_items(self) if not children: p = datagate.create_item(creatorid=creator.id, parentid=g.id) p.name = 'percent' p.percent = 0 p.save() ques = datagate.create_item(creatorid=creator.id, parentid=g.id) ques.name = 'quesId' else: ques = g.search1(name='quesId') listName = (str(g.name) + "IDlist").replace(' ', '') ques.quesId = d[listName] ques.save() for s in sets: childs = s.get_child_items(self) if not childs: questions = datagate.create_item(creatorid=creator.id, parentid=s.id) questions.name = "quesId" else: questions = s.search1(name='quesId') listName2 = (str(s.name) + "IDlist").replace(' ', '') questions.quesId = d2[listName2] questions.save() setsid = request.getvalue('setsid', '') sets = datagate.get_item(setsid) setList = [] for item in sets: cbname = item.name + "_cb" cb = request.getvalue(cbname, '') if cb == "on": setList.append(item.name) if setList == []: group.sets = '' else: group.sets = setList else: #action = "closeQuestions", or else I have no idea how you got here group.sets = '' group.save() # finally, return the meeting (since we might have created it here) return meeting
def process_admin_actions(self, request): '''Process all item actions''' meeting = datagate.get_item(request.getvalue('global_meetingid', '')) action = request.getvalue('_mhaction', '') if action == 'copyitem': meeting = datagate.copy_deep(request.getvalue('_copyitemid', ''), Directory.meetings_item.id) meeting.name = request.getvalue('_itemname', '') meeting.save() return meeting elif action == 'import': try: importfile = request.form['subaction'] gz = gzip.GzipFile(importfile.filename, 'r', fileobj=importfile.file) doc = xml.dom.minidom.parse(gz) except IOError: raise IOError, 'An error occurred while importing the file. Are you sure it is a gzipped XML document (exported from GroupMind)?' return Directory.import_meeting(doc, request.session.user.id) activities_item = meeting.search1(name='activities') groups_item = meeting.search1(name='groups') if action == 'editname': itemname = request.getvalue('activityname', '') if itemname != '': child = activities_item.get_child(request.getvalue('activityid')) child.name = itemname child.save() elif action == 'addactivity': # create the activity name = request.getvalue('name', '') if name != '': activity = datagate.create_item(creatorid=request.session.user.id, parentid=activities_item.id) activity.name = name activity.previousid = request.getvalue('previousid', '') activity.view = request.getvalue('viewtype', '') activity.save() # allow the activity view to initialize itself BaseView.views[activity.view.lower()].initialize_activity(request, activity) elif action == 'delactivity': datagate.del_item(request.getvalue('activityid', '')) elif action == 'moveactivity': activity = datagate.get_item(request.getvalue('activityid')) parent = activity.get_parent() parent.remove_child(activity) parent.insert_child(activity, request.getvalue('previousid')) parent.save() elif action == 'addgroup': name = request.getvalue('name', '') if name != '': group = datagate.create_item(creatorid=request.session.user.id, parentid=groups_item.id) group.name = name group.save() elif action == 'delgroup': datagate.del_item(request.getvalue('groupid', '')) elif action == 'groupusers': submit = request.getvalue('submit', '') group = groups_item.get_child(request.getvalue('_groupid', '')) if submit == '->': group_users = [ child.user_id for child in group.get_child_items() ] for user_id in request.getlist('_allusers'): if not user_id in group_users: child = datagate.create_item(creatorid=request.session.user.id, parentid=group.id) child.user_id = user_id child.save() elif submit == '<-': for user_id in request.getlist('_members'): for child in group.get_child_items(): if child.user_id == user_id: datagate.del_item(child.id) break # finally, return the meeting (since we might have created it here) return meeting
def remove_item_action(self, request): datagate.del_item(request.getvalue("itemid", "")) return ['processRemove("' + request.getvalue("itemid", "") + '")']
def delete_comment_action(self, request, itemid): '''Responds to a delete event from the browser''' datagate.del_item(itemid) return Event('processDelete', itemid)
def remove_item_action(self, request): datagate.del_item(request.getvalue('itemid', '')) return [ 'content.processRemove("' + request.getvalue('itemid', '') + '")' ]