Skip to content
Browse files

itworks

  • Loading branch information...
1 parent 8ff40a8 commit 04fb6aa7bba5495028233fe44d503b8da52deb8f Paul Korzhyk committed
View
3 apps/hello_world/forms.py
@@ -21,4 +21,5 @@ class NewActivityForm(Form):
title = fields.TextField('Short description', validators=[REQUIRED])
date = fields.DateField('Start date', format='%d/%m/%Y', validators=[REQUIRED])
description = fields.TextAreaField('Full activity details')
- participants = fields.IntegerField('Participants (including you)', validators=[REQUIRED])
+ participants = fields.IntegerField('Participants (including you)', validators=[REQUIRED])
+ instructions_for_joined = fields.TextAreaField('Welcome text (meeting location, payment details, requests for additional info)')
View
BIN apps/hello_world/forms.pyc
Binary file not shown.
View
18 apps/hello_world/handlers.py
@@ -9,6 +9,8 @@
import forms
import simplejson
+from models import Activity
+
from tipfy.ext.session import SessionMiddleware, SessionMixin, AllSessionMixins
from tipfy.ext.auth import MultiAuthMixin, login_required, user_required
@@ -46,6 +48,7 @@ class MainPageHandler(BaseHandler):
def get(self, **kwargs):
return self.render_response('layout.html')
+
class SandboxHandler(BaseHandler):
@user_required
def get(self):
@@ -53,9 +56,20 @@ def get(self):
@user_required
def post(self):
- if self.form.validate():
+ if not self.form.validate():
self.set_message('error', 'Invalid activity info. Please fix errors and try again.', life=None)
- return self.render_response('cabinet.html', title='Please try %s again' % (val), form=self.form)
+ return self.get()
+ activity = Activity(
+ title=self.form.title.data,
+ description=self.form.description.data,
+ date=self.form.date.data,
+ participants=self.form.participants.data,
+
+ owner=self.auth_current_user.username,
+ )
+ self.set_message('success', 'Great activity. Nice try!', life=None)
+ return redirect('/')
+
@cached_property
def form(self):
View
BIN apps/hello_world/handlers.pyc
Binary file not shown.
View
10 apps/hello_world/models.py
@@ -1,8 +1,8 @@
from google.appengine.ext import db
class Activity(db.Model):
- title = db.StringProperty(required = True)
- description = db.TextProperty()
- when = db.DateTimeProperty(auto_now_add = True)
- owner = db.StringProperty(required = True)
- participants = db.IntegerProperty(required = True)
+ title = db.StringProperty(required = True)
+ description = db.TextProperty()
+ date = db.DateProperty(auto_now_add = True)
+ owner = db.StringProperty(required = True)
+ participants = db.IntegerProperty(required = True)
View
2 templates/cabinet.html
@@ -5,7 +5,7 @@
<h1>{{ title }}</h1>
<p>
-<form action='/sandbox' method='POST'>
+<form action='/sandbox' method='POST' enctype="multipart/form-data" class="tipfy-form">
{{ forms.form_fields(form) }}
<fieldset class="submit">
<input type="submit" name="submit" value="Create activity!">

0 comments on commit 04fb6aa

Please sign in to comment.
Something went wrong with that request. Please try again.