Skip to content

Commit

Permalink
added to Git
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelnferreira committed Nov 22, 2013
1 parent 5f8ce70 commit 36835b7
Show file tree
Hide file tree
Showing 17 changed files with 1,567 additions and 0 deletions.
37 changes: 37 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
application: vaifreteapp
version: 1
runtime: python27
api_version: 1
threadsafe: no

libraries:
- name: django
version: "1.4"

builtins:
- django_wsgi: on

handlers:

- url: /css
static_dir: css

- url: /js
static_dir: js

- url: /images
static_dir: images

- url: /admin/.*
script: main.py
login: admin

- url: /app/.*
script: main.py
login: required

- url: /DeliveryService.*
script: services.py

- url: .*
script: main.py
39 changes: 39 additions & 0 deletions deliveryservice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import datetime
import time
import logging
from protorpc import remote
from protorpc import messages
from models import *

class Delivery(messages.Message):
destination_address = messages.StringField(1, required=True)
dest_lat = messages.StringField(2)
dest_lng = messages.StringField(3)
source_address = messages.StringField(4)
source_lat = messages.StringField(5)
source_lng =messages.StringField(6)
request_user = messages.StringField(7)

class Deliveries(messages.Message):
deliveries = messages.MessageField(Delivery, 1, repeated=True)

class GetDeliveriesRequest(messages.Message):
limit = messages.IntegerField(1, default=10)
user = messages.StringField(2)

class DeliveryService(remote.Service):
@remote.method(GetDeliveriesRequest, Deliveries)
def get_deliveries(self, request):
logging.debug('Received request ' + str(request))

query = DeliverFee.all().order('-request_date_time')

#if request.user:
#query.filter('date <=', when)

deliveries = []
for delivery_model in query.fetch(request.limit):
delivery = Delivery(destination_address=delivery_model.destination_address, dest_lat=delivery_model.dest_lat, dest_lng=delivery_model.dest_lng, source_address=delivery_model.source_address, source_lat=delivery_model.source_lat, source_lng=delivery_model.source_lng, request_user=delivery_model.request_user.email())
deliveries.append(delivery)

return Deliveries(deliveries=deliveries)
Loading

0 comments on commit 36835b7

Please sign in to comment.