def create(self):

    id = self.params.get('shared_view_id')
    view = UserView.get_by_id(int(id))

    config = copy.deepcopy(ShareUser.default_config)

    for col in config:
      key = col['name']
      val = self.params.get(key)
      if val == 'yes':
        col['val']= 'true'
      else:
        col['val']= 'false'

    yaml_data = yaml.dump(config)
    wk = self.params.get('share_users')
    # 改行で分解
    email = ''
    try:
      for e  in wk.split("\n"):
        email = e
        res = {'status':'success'}
        su = ShareUser(share_view_id = view,email = email,config = yaml_data)
        # メールで通知する
        m = NoticeMail()
        m.notice_share(self.request,su)
        su.put()
    except:
        res = {'status':'error','msg':u"%sへの共有に失敗しました" % email}

    self.render(json=self.to_json(res))
  def delete(self):
    id = self.params.get('id')

    res = {'status':'success'}
    su=ShareUser.get_by_id(int(id))
    if su:
      su.delete()
    else:
      res={'status':'error','msg':u"対象のビューが見つかりません(ID:%s)" % id}

    self.render(json=self.to_json(res))
Beispiel #3
0
    def shared_member_list(self):
      #自分のDBをとりだす
      dbs = UserDb.all()
      dbs.filter('user ='******'user_db_id = ',db) 
        for v in views:
          # shareしているユーザの取得
          share_users = ShareUser.all()
          share_users.filter(' share_view_id = ',v)
          for su in share_users:
            if su.email in  members:
              members[su.email].append(su)
            else:
              members[su.email]=[su]

          self.member_list = []
          for m in members.keys():
            self.member_list.append({'email':m,'share_views':members[m]})