def getAllTags():
    tagslist=memcache.get('alltags')
    if not tagslist:
        tagslist=[]
        for tag in Tag.all():
            tagslist.append({'id':tag.key().id(),'name':tag.name})
        memcache.set('alltags',tagslist,36000)
    return tagslist
    def get(self):
        groupId=self.request.get("GroupId",0)
#        username=
        group={}
        if groupId:
#            group=Group.get_by_id(int(groupId))
            group=getGroup(int(groupId))
        self.render('templates/groupAdd.html',{'group':group,'taglist':Tag.all()})
    def get(self):
        groupid=self.request.get('groupid')
        tagmap={}
        for tag in Tag.all():
            tagmap[str(tag.key().id())]=tag.name

        username=get_current_user(self)
        user=getorAddUser(username)
        if groupid:
            groupid=int(groupid)
#            group=Group.get_by_id(groupid)
            group=getGroup(groupid)
            if group.author==username:
                group.delete()
                nlist=[]
                rnlist=[]
                for n in Note.all().filter('group =',groupid):
                    nlist.append(n)
                    rnlist.append('r'+str(n.key().id()))
                db.delete(Replay.get_by_key_name(rnlist))
                db.delete(nlist)
                if groupid in user.createGroup:
                    user.createGroup.remove(groupid)
                    user.put()
                if groupid in user.createGroupAdd:
                    user.createGroupAdd.remove(groupid)
                    user.put()


        groupidlist=user.createGroup+user.createGroupAdd
        list=Group.get_by_id(groupidlist)
#        list=Group.all().filter('author =',username)
        listgroup=[]
        ischange=False
        for i,group in enumerate(list):
            if not group:
                if groupidlist[i] in user.createGroup:
                    user.createGroup.remove(groupidlist[i])
                    ischange=True
                if groupidlist[i] in user.createGroupAdd:
                    user.createGroupAdd.remove(groupidlist[i])
                    ischange=True
            else:
                group.tagname=tagmap.get(str(group.tag),'')
                listgroup.append(group)
        if ischange:
            user.put()
        self.render('templates/removegroupList.html',{'list':listgroup})
 def post(self):
     tagmap={}
     for tag in Tag.all():
         tagmap[str(tag.key().id())]=tag.name
     username=get_current_user(self)
     if '000'==username:
         type=self.request.get('type','')
         value=self.request.get('value',0)
         list=[]
         if type=='username':
             list=Group.all().filter('author =',str(value))
         if type=='groupid':
             list=Group.get_by_id([int(value)])
     else:
         list=Group.all().filter('author =',username)
     listgroup=[]
     for group in list:
         group.tagname=tagmap.get(str(group.tag),'')
         listgroup.append(group)
     self.render('templates/groupList.html',{'list':listgroup,'tagmap':tagmap,'isadmin':('000'==username and [True] or [False])[0]})
Esempio n. 5
0
 def get(self):
     self.render('templates/group.html',{'grouplist':Group.all(),'taglist':Tag.all()})