Пример #1
0
 def get(self, id):
     id = urllib.unquote(urllib.unquote(id))
     greetings = FotosDB.get_by_id(int(id))
     if greetings.user == users.get_current_user().nickname():
         greetings.delete()
     else:
         pass
     return self.redirect('/fotos/%s' % users.get_current_user().nickname())
Пример #2
0
 def get(self, id):
     id = urllib.unquote(urllib.unquote(id))
     foto = FotosDB.get_by_id(int(id))
     user = users.get_current_user().nickname()
     if foto.user == user:
         dell = True
     else:
         dell = False
     template_values = {
         'upload_url':'/uploadfoto',
         'fotoid': id,
         'fotoinf':foto,
         #'paging':paging,
         'dell':dell,
         }
     self.generate('fotos.foto.html', template_values, razdel = '', logo = 'logo', title = 'Фото %s' % id);
     pass
Пример #3
0
 def post(self, id):
     if users.get_current_user():
         id = urllib.unquote(urllib.unquote(id))
         foto = FotosDB.get_by_id(int(id))
         user = users.get_current_user()
         if foto.user == user.nickname():
             dbuser = UsersDB.gql("WHERE user = '******'" % user.nickname())
             usert = dbuser.get()
             foto = foto.foto
             avatar = images.resize(foto, 100, 100)
             avatar_mob = images.resize(foto, 50, 50)
             avatar_big = foto
             usert.avatar = db.Blob(avatar)
             usert.avatar_mob = db.Blob(avatar_mob)
             usert.avatar_big = db.Blob(avatar_big)
             usert.put()
         pass
     return self.redirect('/fotoc/%s' % id)
     pass
Пример #4
0
    def post(self):
        if users.get_current_user():
            self.pc = 100
            self.big = 500
            self.mob = 50
            self.max_size = 1024 * 1024
            upload_files = self.request.get('foto')

            if upload_files:
                user = users.get_current_user()
                usert = FotosDB()
                image = upload_files
                
                img = images.Image(image)

                if len(image) >= self.max_size:
                    return self.redirect('/fotos/%s?msg=%s' % (users.get_current_user(), u'Max size 1MB'))

                if img.width >= self.pc or img.height >= self.pc:
                    foto_pc = images.resize(image, self.pc, self.pc)
                else:
                    foto_pc = image

                if img.width >= self.mob or img.height >= self.mob:
                    foto_mob = images.resize(image, self.mob, self.mob)
                else:
                    foto_mob = image

                if img.width >= self.big or img.height >= self.big:
                    foto_big = images.resize(image, self.big, self.big)
                else:
                    foto_big = image

                usert.foto = db.Blob(image)
                usert.foto_mob = db.Blob(foto_mob)
                usert.foto_big = db.Blob(foto_big)
                usert.foto_pc = db.Blob(foto_pc)
                usert.user = user.nickname()
                usert.put()
        return self.redirect('/fotos/%s' % users.get_current_user())
Пример #5
0
 def get(self, mode, ruser):
     self.valid_chars = frozenset("0123456789")
     self.response.headers['Content-Type'] = "image/png"
     no_valid = False
     if ruser is int:
         ruser = ruser
     for n in ruser:
         if n in self.valid_chars:
             pass
         else:
             no_valid = True
     if no_valid:
         fname = 'img_m.txt'
         img_f = open(fname, 'r')
         image = img_f.read()
         return self.response.out.write(image)
     else:
         ruser = urllib.unquote(urllib.unquote(ruser))
         mode = urllib.unquote(urllib.unquote(mode))
         foto_get = FotosDB.get_by_id(int(ruser))
         if mode == 'big':
             foto = foto_get.foto_big
         elif mode == 'pc':
             foto = foto_get.foto_pc
         if mode == 'big':
             foto = foto_get.foto_big
         elif mode == 'mob':
             foto = foto_get.foto_mob
         if mode == 'big':
             foto = foto_get.foto_big
         elif mode == 'org':
             foto = foto_get.foto
         if foto:
             return self.response.out.write(foto)
         else:
             fname = 'img_m.txt'
             img_f = open(fname, 'r')
             image = img_f.read()
             return self.response.out.write(image)