Commit 8fdf806e authored by Willard's avatar Willard

Merge restyle into master

parents 8c43b975 578bd7d6
......@@ -5,8 +5,8 @@ from wtforms.validators import DataRequired, EqualTo, Email
from models import Owner, Stall, Dish
class OwnerLoginForm(FlaskForm):
username = StringField('Username', [DataRequired()])
password = PasswordField('Password', [DataRequired()])
username = StringField('Username', [DataRequired()], render_kw={"placeholder": "Username"})
password = PasswordField('Password', [DataRequired()], render_kw={"placeholder": "Password"})
def validate(self):
if not FlaskForm.validate(self):
......@@ -23,11 +23,11 @@ class OwnerLoginForm(FlaskForm):
return True, owner
class OwnerRegisterForm(FlaskForm):
email = StringField('Email', [DataRequired(), Email()])
name = StringField('Name', [DataRequired()])
username = StringField('Username', [DataRequired()])
password = PasswordField('Password', [DataRequired()])
confirm_password = PasswordField('Confirm Password', [EqualTo('password')])
email = StringField('Email', [DataRequired(), Email()], render_kw={"placeholder": "E-mail"})
name = StringField('Name', [DataRequired()], render_kw={"placeholder": "Name"})
username = StringField('Username', [DataRequired()], render_kw={"placeholder": "Username"})
password = PasswordField('Password', [DataRequired()], render_kw={"placeholder": "Password"})
confirm_password = PasswordField('Confirm Password', [EqualTo('password')], render_kw={"placeholder": "Confirm Password"})
def validate(self):
if not FlaskForm.validate(self):
......@@ -45,8 +45,8 @@ class OwnerRegisterForm(FlaskForm):
return True
class StallRegisterForm(FlaskForm):
name = StringField('Name', [DataRequired()])
description = TextAreaField('Description', [DataRequired()])
name = StringField('Name', [DataRequired()], render_kw={'placeholder': 'Name'})
description = TextAreaField('Description', [DataRequired()], render_kw={'placeholder': 'Describe your stall'})
image = FileField('Image')
location = SelectField(coerce=int)
editing = False
......
......@@ -21,7 +21,7 @@ class NewStallView(FormView):
db.session.commit()
return redirect(url_for('view_stall', stall_id=self.stall.id))
def render_get(self):
return render_template('newstall.html', form=self.get_form())
return render_template('stallinfo.html', form=self.get_form(), title='Register Stall', form_action=url_for('new_stall'), submit_label='Submit')
def get_form(self):
form = StallRegisterForm()
form.location.choices = [(loc.id, loc.name) for loc in Location.query.all()]
......@@ -51,7 +51,7 @@ class EditStallView(FormView):
form.name.data = self.stall.name
form.description.data = self.stall.description
form.location.data = self.stall.location_id
return render_template('editstall.html', form=form, stall=self.stall)
return render_template('stallinfo.html', form=form, stall=self.stall, title='Edit Info', form_action=url_for('view_stall', stall_id=self.stall.id), submit_label='Edit')
def get_form(self):
form = StallRegisterForm()
form.location.choices = [(loc.id, loc.name) for loc in Location.query.all()]
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
.btn-lg {
border-radius: 0px;
}
.form-group-lg .form-control {
border-radius: 0px;
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6,14 +6,29 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> {% block head %}
<title>Canteeneo - {% block title %}{% endblock%}</title>
{% endblock %}
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/custom.css') }}">
</head>
<body>
<div class="flex-container">
{% with messages = get_flashed_messages() %} {% if messages %} {% for message in messages %}
<span>{{ message }}</span><br> {% endfor %} {% endif %} {% endwith %} {% block content %} {% endblock %}
<div class="container-fluid">
<div class="row">
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-danger alert-dismissible" role="alert">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
{% endif %}
{% endwith %}
</div>
{% block content %} {% endblock %}
</div>
</body>
<script src="{{ url_for('static', filename='jquery-ajax.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery-3.1.1.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
</html>
\ No newline at end of file
......@@ -3,8 +3,46 @@
{% block title %}Landing Page{% endblock %}
{% block content %}
<div class="dashboard-row">
<a href="/login"><button class="link-button">Login</button></a>
<a href="/register"><button class="link-button">Register</button></a>
<div class="row">
<div class="col-md-4 col-md-offset-2">
<div style="padding: 5%;">
<h1>Login</h1>
<form method="POST" action="/login">
{{ login_form.csrf_token }}
<div class="form-group form-group-lg">
{{ login_form.username(class_="form-control") }}
</div>
<div class="form-group form-group-lg">
{{ login_form.password(class_="form-control") }}
</div>
<button class="btn btn-primary btn-block btn-lg" type="submit">Login</button>
</form>
</div>
</div>
<div class="col-md-4">
<div style="padding: 5%;">
<h1>Register</h1>
<form method="POST" action="/register">
{{ register_form.csrf_token }}
<div class="form-group form-group-lg">
{{ register_form.email(class_="form-control") }}
</div>
<div class="form-group form-group-lg">
{{ register_form.name(class_="form-control") }}
</div>
<div class="form-group form-group-lg">
{{ register_form.username(class_="form-control") }}
</div>
<div class="form-group form-group-lg">
{{ register_form.password(class_="form-control") }}
</div>
<div class="form-group form-group-lg">
{{ register_form.confirm_password(class_="form-control") }}
</div>
<button class="btn btn-primary btn-block btn-lg" type="submit">Register</button>
</form>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% block title %}Login{% endblock %}
{% block content %}
<form method="POST" action="/login">
{{ form.csrf_token }}
<div id="login-form">
<div class="form-input">
<div class="input-row">
{{ form.username.label(class_="field-label") }}
{{ form.username(class_="text-field") }}
</div>
<div class="input-row">
{{ form.password.label(class_="field-label") }}
{{ form.password(class_="text-field") }}
</div>
</div>
<button type="submit">Login</button>
</div>
</form>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% block title %}Register your Stall{% endblock %}
{% block content %}
<h1>Stall Info</h1>
<form action="{{url_for('new_stall')}}" method="POST">
{{ form.csrf_token }}
<div id="form">
<div class="form-input">
<div class="input-row">
{{ form.name.label(class_="field-label") }} {{ form.name(class_="text-field") }}
</div>
<div class="input-row">
{{ form.description.label(class_="field-label") }} {{ form.description(class_="text-area", rows=6, cols=32) }}
</div>
<div class="input-row">
{{ form.location.label(class_="field-label") }} {{ form.location(class_="text-field") }}
</div>
</div>
<div class="dashboard-row">
<button type="submit">Add</button>
<a href="{{url_for('stalls')}}"><button type="button" class="link-button">Back</button></a>
</div>
</div>
</form>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% block title %}Register{% endblock %}
{% block content %}
<form method="POST" action="/register">
{{ form.csrf_token }}
<div id="register-form">
<div class="form-input">
<div class="input-row">
{{ form.email.label(class_="field-label")}}
{{ form.email(class_="text-field") }}
</div>
<div class="input-row">
{{ form.name.label(class_="field-label")}}
{{ form.name(class_="text-field") }}
</div>
<div class="input-row">
{{ form.username.label(class_="field-label")}}
{{ form.username(class_="text-field") }}
</div>
<div class="input-row">
{{ form.password.label(class_="field-label")}}
{{ form.password(class_="text-field") }}
</div>
<div class="input-row">
{{ form.confirm_password.label(class_="field-label")}}
{{ form.confirm_password(class_="text-field") }}
</div>
</div>
<button type="submit">Register</button>
</div>
</form>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1>Stall Info</h1>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<form action="{{ form_action }}" method="POST">
{{ form.csrf_token }}
<div class="form-group form-group-lg col-sm-8">
{{ form.name(class_="form-control") }}
</div>
<div class="form-group form-group-lg col-sm-12">
{{ form.description(class_="form-control", rows=16) }}
</div>
<div class="form-group form-group-lg col-sm-12">
{{ form.location.label(class_="col-sm-6 control-label") }} {{ form.location(class_="form-control") }}
</div>
<div class="form-group form-group-lg">
<div class="col-sm-6">
<button class="btn btn-primary btn-block btn-lg" type="submit">{{ submit_label }}</button>
</div>
<div class="col-sm-6">
<a href="{{url_for('stalls')}}"><button class="btn btn-default btn-block btn-lg" type="button">Back</button></a>
</div>
</div>
</form>
</div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -3,32 +3,40 @@
{% block title %}Dashboard{% endblock %}
{% block content %}
<div class="dashboard-container">
<div class="dashboard-row" style="justify-content: space-around; align-items: baseline;">
<span style="font-size: 32pt; flex-grow: 2;">Hello, {{ owner.name }}</span>
<a href="{{url_for('new_stall')}}"><button class="link-button" style="flex-grow: 1;">Register a Stall</button></a>
<a href="{{url_for('logout')}}"><button class="link-button" style="flex-grow: 1;">Logout</button></a>
<div class="row">
<div class="col-sm-4 col-sm-offset-2">
<h1>Hello, {{ owner.name }}</h1>
</div>
<div class="dashboard-row">
<div class="list">
{% if stalls|length > 0 %}
{% for stall in stalls %}
<div class="list-item" style="width: 100%;">
<div class="list-info">
<span class="list-name">{{stall.name}}</span>
</div>
<div class="dashboard-row">
<a href="{{ url_for('view_stall', stall_id=stall.id) }}"><button class="list-button">Manage Stall</button></a>
<form action="{{ url_for('delete_stall', stall_id=stall.id) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete {{stall.name}}?');">
<button type="submit" class="list-button button-delete">Delete</button>
</form>
</div>
</div>
{% endfor %}
{% else %}
<p>You have no stalls registered!</p>
{% endif %}
</div>
<div class="col-sm-2">
<a class="btn btn-primary btn-lg" href="{{url_for('new_stall')}}">Register a Stall</a>
</div>
<div class="col-sm-2">
<a class="btn btn-default btn-lg" href="{{url_for('logout')}}">Logout</a>
</div>
</div>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
{% if stalls|length > 0 %}
<table class="table">
{% for stall in stalls %}
<tr>
<td>
<h1>{{ stall.name }}</h1>
</td>
<td>
<a class="btn btn-default btn-lg" href="{{ url_for('view_stall', stall_id=stall.id) }}">Manage Stall</a>
</td>
<td>
<form action="{{ url_for('delete_stall', stall_id=stall.id) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete {{stall.name}}?');">
<button class="btn btn-danger btn-lg" type="submit" class="list-button button-delete">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>You have no stalls registered!</p>
{% endif %}
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %} {% block title %} {{stall.name}} {% endblock %} {% block content %}
<div class="dashboard-container">
<div class="dashboard-row">
<span style="font-size: 32pt; flex-grow: 2;">
{{stall.name}}
</span>
<a href="{{ url_for('new_dish', stall_id=stall.id) }}"><button class="link-button" style="flex-grow: 1;">Add Dish</button></a>
<a href="{{ url_for('edit_stall', stall_id=stall.id) }}"><button class="link-button" style="flex-grow: 1;">Edit Info</button></a>
</div>
<div class="dashboard-row">
<div class="list">
{% if dishes|length > 0 %} {% for dish in dishes %}
<div class="list-item">
<div class="list-image">
<img width="200px" height="200px" src="{{url_for('static', filename='uploads/'+dish.image_path)}}" alt="">
</div>
<div class="list-info">
<span class="list-name">{{dish.name}}</span>
<span class="list-price">Php {{dish.price|int}}</span>
<div>
<a href="{{ url_for('edit_dish', stall_id=stall.id, dish_id=dish.id) }}"><button class="list-button">Edit</button></a>
<form action="{{ url_for('delete_dish', stall_id=stall.id, dish_id=dish.id) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete {{dish.name}}')">
<button type="submit" class="list-button button-delete">Delete</button></a>
</form>
</div>
</div>
</div>
{% endfor %} {% endif %}
<div class="row">
<div class="col-md-4 col-md-offset-2">
<span style="font-size: 32pt; flex-grow: 2;">
{{stall.name}}
</span>
</div>
<div class="col-md-4 col-md-offset-1">
<a class="btn btn-primary btn-lg" href="{{ url_for('stalls') }}">Dashboard</a>
<a class="btn btn-default btn-lg" href="{{ url_for('new_dish', stall_id=stall.id) }}">Add Dish</a>
<a class="btn btn-default btn-lg" href="{{ url_for('edit_stall', stall_id=stall.id) }}">Edit Info</a>
</div>
</div>
<div class="dashboard-row">
<a href="{{ url_for('stalls') }}"><button class="link-button">Dashboard</button></a>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
{% if dishes|length > 0 %}
<table class="table">
<tr>
<th>Image</th><th>Name</th><th>Description</th><th>Price</th><th>Controls</th>
</tr>
{% for dish in dishes %}
<tr>
<td><img width="160px" height="160px" src="{{url_for('static', filename='uploads/'+dish.image_path)}}" alt=""></td>
<td>{{dish.name}}</td>
<td>{{dish.description}}</td>
<td>Php {{dish.price}}</td>
<td>
<a class="btn btn-primary btn-block btn-lg "href="{{ url_for('edit_dish', stall_id=stall.id, dish_id=dish.id) }}">Edit</a>
<form action="{{ url_for('delete_dish', stall_id=stall.id, dish_id=dish.id) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete {{dish.name}}')">
<button type="submit" class="btn btn-danger btn-block btn-lg">Delete</button></a>
</form>
</td>
</tr>
{% endfor %}
</table>
{% endif %}
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -37,7 +37,7 @@ class LoginView(FormView):
login_user(Owner.query.filter_by(username=self.get_form().username.data).first())
return redirect(url_for('stalls'))
def render_get(self):
return render_template('login.html', form=self.get_form())
return redirect('/')
def get_form(self):
return OwnerLoginForm()
......@@ -48,9 +48,9 @@ class RegisterView(FormView):
owner = Owner(form.name.data, form.username.data, form.email.data, form.password.data)
db.session.add(owner)
db.session.commit()
return redirect(url_for('login'))
return redirect(url_for('register'))
def render_get(self):
return render_template('register.html', form=self.get_form())
return redirect('/')
def get_form(self):
return OwnerRegisterForm()
......@@ -60,7 +60,7 @@ app.add_url_rule('/register', view_func=RegisterView.as_view('register'))
@app.route('/')
@not_logged_in
def index():
return render_template('landing.html')
return render_template('landing.html', login_form=OwnerLoginForm(), register_form=OwnerRegisterForm())
@app.route('/logout')
def logout():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment