Source

rankademy / www / templates / users.html

Full commit
{% extends "index.html" %}
{#
to import macros:
	{% from "businesses.html" import show_businesses %}
#}
{% block title %} User homepage {% endblock %}

{% block code %}
    {{ super() }}
    <script type="text/javascript" 
        src="{{url_for("static", filename = "js/views/users.js")}}"></script>

{% endblock %}




{% macro render_new_user() %}
	{% import "forms.html" as forms %}

	<div id = "dialog-new-user" title = "Add new user" class = "span8">
		{%
		set options = 	[dict( value = "student", label = "I am student."),
						dict(value = "lecturer", label = "I am lecturer.")]
		%}
		{%
		set elems = [
			dict(name = "first_name", label = "First name", tag = "input", type = "text"),
			dict(name = "last_name", label = "Last name", tag = "input"),
			dict(name = "headline", label = "Headline", tag = "input"),
			dict(name = "interests", label = "Interests", tag = "input"),
			dict(name = "portrait", label = "Profile pic", tag = "fileinput"),
			dict(name = "roles", label = "Current roles", tag = "options"),
			dict(name = "university", label = "University", tag = "input")
		]
		%}

			
	<form action = "{{url_for('user.index')}}" method = "POST" enctype="multipart/form-data">
		
		{% for elem in elems %}
			<div class = "clearfix">
				<label for = "{{elem.name}}">{{elem.label}}:</label>
				<div class = "input">
				{%if elem.tag == "input" %}	
					{{ forms.input(elem.name, elem.type) }}
				{% elif elem.tag == "textarea" %}
					{{ forms.textarea(elem.name) }}
				{% elif elem.tag == "options" %}
					{{ forms.options(elem.name, elem.title, options) }}
				{% elif elem.tag == "fileinput" %}
					{{ forms.fileinput(elem.name) }}	
				{% else %}
					{{ forms.input(elem.name, "hidden") }}
				{% endif %}
				</div>
			</div> <!-- end of clearfix -->
		{% endfor %}
   	</form>

	</div>
{% endmacro %}


{% block content %}
	{{render_new_user()}}

	<div class = "row">
		<div span = "16">
			<h3>Users</h3>
			<table class = "zebra-striped">
			{% for user in users%}
				<tr>
					<td>
						<a href = "{{url_for("user.index") + "/" + user._id}}">profile</a>
					</td>
					<td>
						{{user.first_name}}, {{user.last_name}}
					</td>
				</tr>
			{% endfor %}
			</table>
		</div>

	</div>
{% endblock %}