Skip to content

Commit

Permalink
Create user form. Still a WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Arx Cruz committed Jan 31, 2015
1 parent 68002e2 commit 624b8d6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
10 changes: 10 additions & 0 deletions dashboard/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from wtforms import BooleanField
from wtforms import Form
from wtforms import TextField
from wtforms import validators

class UserForm(Form):
name = TextField('Name', [validators.Length(min=3, max=128)])
user_id = TextField('User id', [validators.Length(min=4, max=25)])
email = TextField('Email Address', [validators.Length(min=6, max=35)])

2 changes: 1 addition & 1 deletion dashboard/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<ul class="dropdown-menu" role="menu">
<li><a href="{{ url_for('dashboard.dashboard_users') }}">List</a></li>
<li class="divider"></li>
<li><a href="#">Create new User</a></li>
<li><a href="{{ url_for('dashboard.dashboard_create_user') }}">Create new User</a></li>
</ul>
</li>
</ul>
Expand Down
16 changes: 8 additions & 8 deletions dashboard/templates/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ <h3>{{ team.name }}</h3>
{% endmacro %}

{% macro render_field(field) %}
<dt>{{ field.label }}
<dd>{{ field(**kwargs)|safe }}
{% if field.errors %}
<ul class=errors>
<div class="control-group{% if field.errors %} error {% endif %}">
{{ field.label(class="control-label") }}
<div class="controls">
{{ field(**kwargs) }}
{% for error in field.errors %}
<li>{{ error }}</li>
<span class="help-inline">{{ error }}</span>
{% endfor %}
</ul>
{% endif %}
</dd>
</div>
</div>

{% endmacro %}
18 changes: 18 additions & 0 deletions dashboard/templates/create_user.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends 'base.html' %}

{% from 'common.html' import render_field %}

{% block title %}Stackquery - Create user{% endblock title%}

{% block java_script %}

{% endblock java_script %}

{% block main %}
<form method="POST" action="{{ url_for('dashboard.dashboard_create_user') }}">
{{ render_field(form.name) }}
{{ render_field(form.user_id) }}
{{ render_field(form.email) }}
<p><input type="submit" value="Create"></p>
</form>
{% endblock main %}

0 comments on commit 624b8d6

Please sign in to comment.