Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Create, list and almost view working
Browse files Browse the repository at this point in the history
  • Loading branch information
DFectuoso committed Jun 4, 2010
1 parent 209d758 commit 1b9d8e2
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.swp
24 changes: 19 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import urllib
import urllib2
import hashlib

import time
import datetime

from google.appengine.api import mail
from google.appengine.ext import webapp, db
from google.appengine.api import urlfetch, memcache, users
Expand All @@ -14,23 +16,34 @@
class HackUp(db.Model):
user = db.UserProperty(auto_current_user_add=True)
details = db.StringProperty(required=True, multiline=True)
address = db.StringProperty(required=True, multiline=True)
created = db.DateTimeProperty(auto_now_add=True)
when = db.DateTimeProperty(auto_now_add=True)

# Handlers:
class ViewHandler(webapp.RequestHandler):
def get(self,id):
user = users.get_current_user()
self.response.out.write(template.render('templates/view.html', locals()))
idInt = 0
try:
idInt = int(id)
hackup = HackUp.get_by_id(idInt)
if (hackup):
self.response.out.write(template.render('templates/view.html', locals()))
else:
self.redirect('/')
except:
self.redirect('/')

class CreateHandler(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
self.response.out.write(template.render('templates/create.html', locals()))

def post(self, update_id):
def post(self):
user = users.get_current_user()
t = time.strptime(self.request.get("when"), "%d/%m/%Y")
dt = datetime.datetime(*t[0:5])
hackup = HackUp(user=user, details=self.request.get("descripcion","El fail user no escribio nada fail"), when=dt)
hackup.put()
self.redirect('/')

class ConfirmHandler(webapp.RequestHandler):
Expand All @@ -45,6 +58,7 @@ def get(self):
logout_url = users.create_logout_url('/')
else:
login_url = users.create_login_url('/')
hackups = HackUp.all().filter("when >", datetime.datetime.now())
self.response.out.write(template.render('templates/main.html', locals()))

def main():
Expand Down
2 changes: 1 addition & 1 deletion static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ h3 { margin-top: 0px;}
h4 { margin-bottom: 0px;}

table td { padding-left: 10px; padding-top: 4px;}

form textarea { width: 400px; height: 100px;}
form div { margin-top: 10px; }

label { display: block; font-size: smaller;}
Expand Down
16 changes: 15 additions & 1 deletion templates/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@

<h3>Crear un hackup</h3>
<div id="hackups">
Aqui va la forma de los hackups
<form method="POST">
<div>
Descripcion:
<textarea name="descripcion">
En este lugar escribe donde va a ser, de que hora a que hora y una manera de contactarte
</textarea>
</div>
<div>
Cuando va a ser: FORMATO (DD/MM/AAAA)
<input type="text" name="when"></input>
</div>
<div>
<input type="submit">Crear</input>
</div>
</form>
</div>
{% endblock %}
6 changes: 6 additions & 0 deletions templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

<h3>Next hackups</h3>
<div id="hackups">
{% for hackup in hackups %}
<hr/>
<div>Fecha:{{hackup.when}}</div>
<div>Descripcion:{{hackup.details}}</div>
<div><a href="/view/{{hackup.key.id}}">Ver detalles</a></div>
{% endfor %}
Aqui van a ir los hackups
</div>
{% endblock %}

0 comments on commit 1b9d8e2

Please sign in to comment.