Skip to content

Commit

Permalink
Final
Browse files Browse the repository at this point in the history
  • Loading branch information
prakhar1989 committed Jul 28, 2012
1 parent 9f7e09f commit 532c5e5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app.yaml
@@ -1,4 +1,4 @@
application: temporary-jokastore
application: jokastore
version: 1
runtime: python27
api_version: 1
Expand Down
26 changes: 22 additions & 4 deletions main.py
Expand Up @@ -9,6 +9,7 @@
from google.appengine.api import memcache
from google.appengine.api import users
from webapp2_extras import sessions
from google.appengine.api import mail

template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir),
Expand Down Expand Up @@ -95,7 +96,7 @@ class MainPage(Handler):
to display all items. Use this in emergency by changing routing
mappings. Currently mapped to /mainpage"""
def get(self):
tshirts = get_tshirts()
tshirts = get_tshirts(update = True)
self.render("main.html", tshirts = tshirts)

class AnotherMainPage(Handler):
Expand All @@ -106,7 +107,7 @@ def get(self):

class JSONHandler(Handler):
def get(self):
tshirts = get_tshirts()
tshirts = get_tshirts(True)
self.response.headers['Content-type'] = 'application/json'
tshirt_json = []
for t in tshirts:
Expand Down Expand Up @@ -239,7 +240,22 @@ def post(self):
self.redirect('/item/edit')


app = webapp2.WSGIApplication([('/', AnotherMainPage),
class EmailHandler(Handler):
def get(self):
sender_address = "prakhar1989@gmail.com"
user_address = "kumarar2013@iimcal.ac.in"
subject = "Hi, from Jokastore"
body = "Thanks for purchasing from Jokastore"
mail.send_mail(sender_address, user_address, subject, body)


class ListOrdersHandler(Handler):
def get(self):
orders = db.GqlQuery("SELECT * FROM Order ORDER BY time_of_order")
self.response.headers['Content-type'] = 'text/plain'
self.render("list_orders.html", orders = orders)

app = webapp2.WSGIApplication([('/', MainPage),
('/logout', LogoutHandler),
('/login', LoginHandler),
('/item/add', AddItemHandler),
Expand All @@ -251,5 +267,7 @@ def post(self):
('/cart', CartHandler),
('/all.json', JSONHandler),
('/checkout', CheckoutHandler),
('/sendmail', EmailHandler),
('/listorders', ListOrdersHandler),
('/secure', SecureHandler),
('/tshirt/(\d+)', ShowItemHandler)], config=config)
('/tshirt/(\d+)', ShowItemHandler)], config=config, debug=True)
3 changes: 3 additions & 0 deletions templates/list_orders.html
@@ -0,0 +1,3 @@
{% for o in orders %}
{{ o.user_email }},{{ o.qty}},{{o.size}},{{o.tshirt_id}}
{% endfor %}
2 changes: 1 addition & 1 deletion templates/show_tshirt.html
Expand Up @@ -19,7 +19,7 @@ <h3 style="float: right;"><span class="WebRupee">Rs.</span> 325 </h3>
</ul>
<div class="input-prepend">
Quantity <input type="text" id="qty_input" class="input-mini" />
<a href="http://dl.dropbox.com/u/9555677/size_chart.jpg" target="_blank" title="Download Size Chart"><i class="icon-download-alt"></i></a>
<a href="http://esparsha.com/docs/size_chart.pdf" target="_blank" title="Download Size Chart"><i class="icon-download-alt"></i></a>
</div>
<div class="add_to_cart">
<a href="/cart" class = "btn btn-primary btn-large cart_btn">Add this to Cart!</a>
Expand Down

0 comments on commit 532c5e5

Please sign in to comment.