-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trip.py
61 lines (46 loc) · 1.54 KB
/
Trip.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
from google.appengine.ext import ndb
from google.appengine.api import memcache
import logging
from Destination1 import *
from Base import *
from Users import *
class Trip(ndb.Model):
name = ndb.StringProperty()
search_name = ndb.StringProperty()
description = ndb.StringProperty()
details = ndb.TextProperty()
links = ndb.StringProperty(repeated = True)
destinations = ndb.KeyProperty(Destination1, repeated = True)
tags = ndb.KeyProperty(Tag, repeated = True)
isPublic = ndb.BooleanProperty()
turl = ndb.StringProperty()
added_by = ndb.KeyProperty(User)
created = ndb.DateTimeProperty(auto_now_add = True)
last_updated_by = ndb.KeyProperty(User)
lastModified = ndb.DateTimeProperty(auto_now = True)
def _pre_put_hook(self):
self.search_name = self.name.upper()
def render(self, view=False):
logging.error('in Trip render')
# self._render_text = self.content.replace('\n', '<br>')
return render_jinja_str("cravel-content-trip.html", t = self, view=view)
@classmethod
def getTripByName(self, name):
name = name.upper()
trips = Trip.query().filter(Trip.search_name == name)
return trips
@classmethod
def getTripByPath(self, path):
trips = Trip.query().filter(Trip.turl == path)
return trips
@classmethod
def getAllTrips(update=True):
#key = 'top'
#dests = memcache.get(key)
#if dests is None or update:
logging.error('DB Query')
trips = Trip.query().order(-Trip.created)
# memcache.set(key, dests)
#else:
# logging.error('No DB Query')
return trips