Пример #1
0
 def insert_description(self):
     try:
         self.function = Function.objects.get(signature=self.attributes["func_signature"])
     except Function.DoesNotExist:
         self.function.save()
     description = Description()
     description.initialize(self.function, self.description_data, self.user)
     description.save()
Пример #2
0
def savebookmark(TitleF,UrlF,DescriptionF,TagF,PrivateF,UserF):
    TitleF = unicode(TitleF)
    UrlF = unicode(UrlF)
    DescriptionF = unicode(DescriptionF)
    Tagf = unicode(TagF)
    try :
        UrlB = Url.objects.get(url=UrlF)
    except :
        UrlB = Url(url=UrlF)
    UrlB.save()

    try :
        TitleB = Title.objects.get(title=TitleF)
    except :
        TitleB = Title(title=TitleF)
    TitleB.save();
    try :
        DescriptionB = Description.objects.get(description=DescriptionF)
    except :
        DescriptionB = Description(description=DescriptionF)
    DescriptionB.save()
    try :
        PrivateB = Private.objects.get(private= (PrivateF == 'True'))
    except :
        PrivateB = Private(private= (PrivateF == 'True'))
    PrivateB.save()
    try :
        b2 = Bookmark.objects.get(url=UrlB)
        b2.title=TitleB
        b2.description=DescriptionB
        b2.private=PrivateB
    except :
        b2 = Bookmark(title=TitleB,url=UrlB,description=DescriptionB,private=PrivateB)
        b2.save()
        b2.user.add(UserF)
    b2.save()

    tags = TagF.split(" ")
    tags.sort()
    for t in tags :
        try :
            TagB = Tag.objects.get(tag=t)
        except :
            TagB= Tag(tag=t)
            TagB.save()
            TagB.user.add(UserF)
        TagB.save()
        b2.tag.add(TagB)
    b2.save()
Пример #3
0
 def UpdateDescription(self):
     """
     """
     description = Description.get_or_insert('description')
     self.response.out.write('<br/><br/><form action="/admin/send_description" method="POST">')
     if description.text:
         d = description.text
     else:
         d = ''
     self.response.out.write('<textarea rows="5" cols="40" wrap="physical" name="description">'+d+'</textarea><br/>')
     self.response.out.write('<input type="submit" value="Submit" /></form>')
Пример #4
0
    def get(self):
        changesets = Changeset.all().order('-created_at').fetch(20)
        counts = Count.all().order('-date').fetch(30)
        counts_list = [c.count for c in counts]
        counts_list.reverse()
        counts_list_str = ','.join(map(str,counts_list))
        config = get_config()
        description = Description.get_or_insert('description').text
        options = {
            'url': self.request.url,
            'config': config, 
            'changesets': changesets, 
            'description': description,
            }
        if counts_list:
            options.update({
                'counts_list': counts_list_str,
                'max_count': max(counts_list),
                'average': sum(counts_list)/len(counts_list),
                })

        path = os.path.join(os.path.dirname(__file__), 'templates/index.html')
        page = template.render(path,options)
        self.response.out.write(page)
Пример #5
0
 def post(self,action=None):
     if action == 'send_description':
         description = Description.get_or_insert('description')
         description.text = self.request.get("description")
         description.put()
         self.redirect("/admin?message=description%20is%20updated")