当前位置: 首页>>代码示例>>Python>>正文


Python Directory.import_meeting方法代码示例

本文整理汇总了Python中Directory.import_meeting方法的典型用法代码示例。如果您正苦于以下问题:Python Directory.import_meeting方法的具体用法?Python Directory.import_meeting怎么用?Python Directory.import_meeting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Directory的用法示例。


在下文中一共展示了Directory.import_meeting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_admin_actions

# 需要导入模块: import Directory [as 别名]
# 或者: from Directory import import_meeting [as 别名]
  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()

#.........这里部分代码省略.........
开发者ID:ssaltzman,项目名称:POET,代码行数:103,代码来源:POET.py

示例2: process_admin_actions

# 需要导入模块: import Directory [as 别名]
# 或者: from Directory import import_meeting [as 别名]
  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
#.........这里部分代码省略.........
开发者ID:ssaltzman,项目名称:POET,代码行数:103,代码来源:POET.py

示例3: process_admin_actions

# 需要导入模块: import Directory [as 别名]
# 或者: from Directory import import_meeting [as 别名]
  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
开发者ID:ssaltzman,项目名称:POET,代码行数:84,代码来源:MeetingHome.py


注:本文中的Directory.import_meeting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。