Wilson Xu avatar Wilson Xu committed 674e97d

Added signup form to homepage.

Comments (0)

Files changed (7)

fbone/templates/home.html

 {% extends "layout.html" %}
 
 {% block body %}
-<p>home</p>
 {% endblock %}
 

fbone/templates/index.html

-{% from 'macros/_misc.html' import render_pagination, render_user_table %}
+{% from "macros/_misc.html" import render_input, render_action %}
 
-{% set page_title = _('Home Page') %}
+{% set page_title = _('Fbone is a flask skeleton.') %}
 
 {% extends 'layout.html' %}
 
 {% block body %}
-<div class="span10">
-    <h2>Main content</h2>
+<div class="span8">
+    <h2>Powered by <a href='http://flask.pocoo.org'>Flask</a> and its <a href='http://flask.pocoo.org/extensions/'>extensions</a>.</h2>
+    <ul>
+        <li>Flask-SQLAlchemy</li>
+        <li>Flask-Login</li>
+        <li>Flask-WTF</li>
+        <li>Flask-Script</li>
+        <li>Flask-Babel</li>
+        <li>Flask-Testing</li>
+        <li>Flask-Mail</li>
+    </ul>
 </div>
-<div class="span4">
+<div class="span6">
     <form class='form-stacked' method="POST" action="{{ url_for('frontend.signup') }}">
-        {{ form.hidden_tag() }}
-        {{ form.next }}
+        {{ signup_form.hidden_tag() }}
+        {{ signup_form.next }}
         <fieldset>
-            <legend>Already have account? <a href="{{ url_for('frontend.login') }}">Login</a> please.</legend>
-            {{ render_input(form.name, True) }}
-            {{ render_input(form.email) }}
-            {{ render_input(form.password) }}
-            {{ render_input(form.password_again) }}
-            {{ render_action(form.submit) }}
+            <legend><h5>Already have account? <a href="{{ url_for('frontend.login') }}">Login</a> please.</h5></legend>
+            {{ render_input(signup_form.name, 'large') }}
+            {{ render_input(signup_form.email, 'large') }}
+            {{ render_input(signup_form.password, 'large') }}
+            {{ render_input(signup_form.password_again, 'large') }}
+            {{ render_action(signup_form.submit) }}
         </fieldset>
     </form>
 </div>

fbone/templates/login.html

         {{ form.next }}
         <fieldset>
             <legend>Not a member? <a href="{{ url_for('frontend.signup') }}">Sign up</a> please.</legend>
-            {{ render_input(form.login, True) }}
-            {{ render_input(form.password) }}
+            {{ render_input(form.login, 'xlarge') }}
+            {{ render_input(form.password, 'xlarge') }}
             <div class='clearfix'>
                 <label></label>
                 <div class="input">

fbone/templates/macros/_misc.html

     {% endif %}
 {% endmacro %}
 
-{% macro render_input(field, autofocus=False) %}
+{% macro render_input(field, cls='') %}
 <div class='clearfix {% if field.errors %}error{% endif %}'>
     {{ field.label }}
     <div class='input'>
-        {% if autofocus %}
-        {{ field(class_='xlarge {% if field.errors %}error{% endif %}', autofocus=autofocus) }}
+        {% if field.errors %}
+        {{ field(class_=cls~' error') }}
         {% else %}
-        {{ field(class_='xlarge {% if field.errors %}error{% endif %}') }}
+        {{ field(class_=cls) }}
         {% endif %}
         <span class="help-inline">
             {% for error in field.errors %}

fbone/templates/signup.html

         {{ form.next }}
         <fieldset>
             <legend>Already have account? <a href="{{ url_for('frontend.login') }}">Login</a> please.</legend>
-            {{ render_input(form.name, True) }}
-            {{ render_input(form.email) }}
-            {{ render_input(form.password) }}
-            {{ render_input(form.password_again) }}
+            {{ render_input(form.name, 'xlarge') }}
+            {{ render_input(form.email, 'xlarge') }}
+            {{ render_input(form.password, 'xlarge') }}
+            {{ render_input(form.password_again, 'xlarge') }}
             {{ render_action(form.submit) }}
         </fieldset>
     </form>

fbone/templates/user.html

 {% extends "layout.html" %}
 
 {% block body %}
-<p>user</p>
 {% endblock %}

fbone/views/frontend.py

 
 @frontend.route('/')
 def index():
-    login_form = None
+    if current_user.is_authenticated():
+        return redirect(url_for('user.home'))
+
+    login_form = signup_form = None
     if not current_user.is_authenticated():
         login_form= LoginForm(next=request.args.get('next'))
+        signup_form = SignupForm(nex=request.args.get('next'))
     page = int(request.args.get('page', 1))
     pagination = User.query.paginate(page=page, per_page=10)
     return render_template('index.html', pagination=pagination, login_form=login_form,
-                           current_user=current_user)
+                           signup_form=signup_form, current_user=current_user)
 
 
 @frontend.route('/search')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.