def listado(): _auth = Auth() if _auth.is_login(): data = {} user = db.GqlQuery("SELECT * FROM User WHERE username = :1", _auth.is_login()).fetch(1)[0] data['series'] = Serie.all().filter("user="******"series/listado.html", data) else: return template("sin-permisos.html")
def login(): """ Iniciar Session """ _auth = Auth() if not _auth.is_login(): return template('auth/login.html') else: message = "Error ya has iniciado Session con la cuenta \"%s\" " %_auth.is_login() message += "en caso de querer proceder por fabor cierra la session actual." return template("message.html", {'message': message} )
def do_registrar(): _auth = Auth() if _auth.is_login(): #field validation _name = request.forms.get('name') _day = request.forms.get('day') _url = request.forms.get('url') _chapter_url = request.forms.get('chapter_url') _num_chapters = request.forms.get('mun_chapters') _old_chapter = request.forms.get('old_chapter') #el usuario existe se supone que esta logueado sino cagada jaaj _user = db.GqlQuery("SELECT * FROM User WHERE username = :1", _auth.is_login()).fetch(1)[0] if _num_chapters <= _old_chapter: _old_chapter = _num_chapters _enabled = False else: _enabled = True serie = Serie( user = _user, name = _name, day = _day, url = _url, chapter_url = _chapter_url, num_chapters = int(_num_chapters), old_chapter = int(_old_chapter), #ultimo capitulo que salio enabled = _enabled ) serie.put() # Registro los capitulos n = int(_old_chapter) + 1 for num in range(1, n): chapter = Chapter( serie = serie, number = num, url = serie.chapter_url %num, show = False ) chapter.put() return "Serie Registrada" #return template("series/registrar.html") else: return template("sin-permisos.html")
def do_registrar(): """ """ _auth = Auth() if not _auth.is_login: errors = [] #errores #validacion de campos vacios _username = request.forms.get('username') if _username == "": errors.append("El campo Usuario esta vacio") #validacion de contrasenias _password = request.forms.get('password') repassword = request.forms.get('repassword') if len(_password) < 8 or len(_password) >= 16: errors.append("la contrasenia debe tener entre 8 y 16 caracteres") if _password != repassword: errors.append("Las contrasenias no coinciden") _name = request.forms.get('name') if _name == "": errors.append("El campo Nombre esta vacio") _email = request.forms.get('email') if _email == "": errors.append("El campo Email esta vacio") if len(errors) == 0: #validacion de que no exista el usuario query = db.GqlQuery("SELECT * FROM User WHERE username = :1", _username) if query.count() != 0: errors.append("El nombre de usuarios \"%s\" ya existe" %_username) form_error = True else: user = User( username = _username, password = _password, name = _name, email = _email, ) user.put() return template("auth/registrar-ok.html") else: form_error = True #si llego hasta aqui hay algun tipo de errors data = { "errors" : errors, "form_error": form_error, "username": _username, "name": _name, "email": _email, } return template("auth/registrar.html", data) else: message = "Error ya has iniciado Session con la cuenta \"%s\" " %_auth.is_login() message += "en caso de querer proceder por fabor cierra la session actual." return template("message.html", {'message': message} )
def index(): #pagina de inicio _auth = Auth() if (_auth.is_login()): is_login = True else: is_login = False return template('home.html', {'is_login':is_login })
def registrar(): _auth = Auth() if _auth.is_login(): return template("series/registrar.html") else: return template("sin-permisos.html")
def debug(): """ Vista Para Pruebas """ a = Auth() return str(a.is_login()),'-', str(a.is_admin())