-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
68 lines (53 loc) · 1.73 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from google.appengine.ext import ndb
import string
class Serie(ndb.Model):
title = ndb.StringProperty()
poster = ndb.StringProperty()
typel = ndb.StringProperty()
plot = ndb.StringProperty()
serieid = ndb.IntegerProperty()
episodes = ndb.IntegerProperty()
air = ndb.StringProperty()
status = ndb.StringProperty()
genres = ndb.StringProperty()
class User(ndb.Model):
name = ndb.StringProperty()
nickname = ndb.StringProperty()
email = ndb.StringProperty()
passw = ndb.StringProperty()
def AllSerie():
return Serie.query()
def FetchSerie(id):
#qry = Serie.query(Serie.serieid == string.atoi(keyid))
keyserie = ndb.Key(Serie, int(id))
serie = keyserie.get()
return serie
def UpdateSerie(id, title, poster, typel, plot,episodes,genres,air,status):
serie = Serie(id=id, title=title, poster=poster, typel=typel, plot=plot,episodes=episodes,genres=genres,air=air,status=status)
serie.put()
return serie
def InsertSerie(serieid, title, poster, typel, plot,episodes,genres,air,status):
serie = Serie(serieid=serieid,poster=poster, typel=typel, plot=plot,episodes=episodes,genres=genres,air=air,status=status)
serie.put()
return serie
def DeleteSerie(id):
key = ndb.Key(Serie, id)
key.delete()
def InsertUser(name, nickname, email, passw):
qry = User.query(User.name == name)
if qry.get() is None:
serie = User(name=name, nickname=nickname, email=email, passw=passw)
serie.put()
return 1
else:
return 0
def CheckUser(name, passw):
qry = User.query(User.name == name)
usuario = qry.get()
if usuario is None:
return None
else:
if usuario.passw==passw:
return usuario.nickname
else:
return None