-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontribution.py
More file actions
34 lines (30 loc) · 907 Bytes
/
contribution.py
File metadata and controls
34 lines (30 loc) · 907 Bytes
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
# -*- coding: utf-8 -*-
from google.appengine.ext import ndb
import logging
import key
import osmEdit
class Contribution(ndb.Model):
chat_id = ndb.IntegerProperty()
date = ndb.DateTimeProperty(auto_now=True)
location = ndb.GeoPtProperty()
node_id = ndb.StringProperty()
search_type = ndb.StringProperty()
picture_file_id = ndb.StringProperty()
def addContribution(person, node_id, file_id):
c = Contribution(
chat_id = person.chat_id,
location = person.location,
search_type = person.search_type,
node_id = node_id,
picture_file_id = file_id
)
c.put()
def deleteContribution(lat, lon):
loc = ndb.GeoPt(lat, lon)
c = Contribution.query(Contribution.location==loc).get()
if c:
node_id = c.node_id
if osmEdit.deleteLocation(node_id):
c.key.delete()
return True
return False