Пример #1
0
 def set_issafe(self):
     for photo in Mask.query():
         if photo.audience <= 2:
             photo.is_safe = True
         else:
             photo.is_safe = False
         photo.put()
Пример #2
0
    def masks(self):

        id_2_delete = self.request.get('delete', None)
        if id_2_delete is not None:
            print 'deleting mask %s' % id_2_delete
            mask = Mask.get_by_id(id_2_delete)
            mask.key.delete()

        template_values = {
            'page': 'masks',
            'link': 'photos',
            'items': Mask.query().fetch()
        }

        template = JINJA_ENVIRONMENT.get_template('admin_masks.html')
        self.response.write(template.render(template_values))
Пример #3
0
    def search_tags(self, csv_tags):
        self.response.headers['Access-Control-Allow-Origin'] = "*"
        tags = [Tag.sanitize(x) for x in csv_tags.split(',')]

        masks_query = Mask.query()

        for tag in tags:
            masks_query = masks_query.filter(
                ndb.AND(Mask._properties['tags'] >= tag),
                Mask._properties['tags'] <= unicode(tag) + u'\ufffd')
        masks = masks_query.order(Mask.tags, -Mask.up_vote,
                                  -Mask.added).fetch()

        reply = []
        for mask in masks:
            reply.append(Mask.to_json_object(mask))

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps(reply))
Пример #4
0
    def get(self):
        self.response.headers['Access-Control-Allow-Origin'] = "*"
        masks_query = Mask.query()

        pg_rating = self.request.get('a',
                                     default_value=0)  # filter for pg rating
        pg_rating = 0 if pg_rating == '' else pg_rating
        if int(pg_rating) > 0:
            masks_query = masks_query.filter(
                Mask._properties['is_safe'] == True)

        masks_query = masks_query.order(-Mask.added, -Mask.up_vote)

        masks = masks_query.fetch()

        reply = []
        for mask in masks:
            reply.append(Mask.to_json_object(mask))

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps(reply))