-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a73c8aa
commit 63fe33b
Showing
15 changed files
with
325 additions
and
27 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Created at 20/1/17 | ||
__author__ = 'Sergio Padilla' | ||
""" | ||
from crispy_forms.bootstrap import FormActions | ||
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import Layout, Submit, Field | ||
from django import forms | ||
from django.forms import IntegerField, CharField, ChoiceField | ||
|
||
|
||
class AddForm(forms.Form): | ||
id = IntegerField() | ||
cuisine = CharField(max_length=100, required=False) | ||
borough = ChoiceField( | ||
choices=( | ||
('Manhattan', "Manhattan"), | ||
('Brooklyn', "Brooklyn"), | ||
('Queens', "Queens"), | ||
('Staten Island', "Staten Island"), | ||
('Bronx', "Bronx") | ||
), | ||
widget=forms.RadioSelect, | ||
initial='Manhattan', | ||
) | ||
name = CharField(max_length=100) | ||
postal_code = IntegerField() | ||
|
||
helper = FormHelper() | ||
helper.form_class = 'form-horizontal' | ||
helper.label_class = 'col-lg-4' | ||
helper.field_class = 'col-lg-4' | ||
helper.layout = Layout( | ||
Field('id', css_class='input-small'), | ||
Field('cuisine', css_class='input-large'), | ||
'borough', | ||
Field('name', css_class='input-large'), | ||
Field('postal_code', css_class='input-small'), | ||
FormActions( | ||
Submit('save_changes', 'Add restaurant', css_class="btn-primary"), | ||
Submit('cancel', 'Cancel'), | ||
) | ||
) | ||
|
||
def clean(self): | ||
self.is_valid() | ||
borough = self.cleaned_data.get('borough') | ||
code = self.cleaned_data.get('postal_code') | ||
|
||
if (borough == 'Manhattan' and 10000 < code < 10044) or (borough == 'Brooklyn' and 11200 < code < 11239) or \ | ||
(borough == 'Queens' and 11690 < code < 11107) or (borough == 'Staten Island' and 10000 < code < 10044)\ | ||
or (borough == 'Bronx' and 10450 < code < 10475): | ||
return self.cleaned_data | ||
|
||
raise forms.ValidationError('The postal code doesn\'t correspond with the borough') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
body { | ||
padding-top: 40px; | ||
padding-bottom: 40px; | ||
background-color: #eee; | ||
} | ||
|
||
.form-signin { | ||
max-width: 330px; | ||
padding: 15px; | ||
margin: 0 auto; | ||
} | ||
.form-signin .form-signin-heading, | ||
.form-signin .checkbox { | ||
margin-bottom: 10px; | ||
} | ||
.form-signin .checkbox { | ||
font-weight: normal; | ||
} | ||
.form-signin .form-control { | ||
position: relative; | ||
height: auto; | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
padding: 10px; | ||
font-size: 16px; | ||
} | ||
.form-signin .form-control:focus { | ||
z-index: 2; | ||
} | ||
.form-signin input[type="email"] { | ||
margin-bottom: -1px; | ||
border-bottom-right-radius: 0; | ||
border-bottom-left-radius: 0; | ||
} | ||
.form-signin input[type="password"] { | ||
margin-bottom: 10px; | ||
border-top-left-radius: 0; | ||
border-top-right-radius: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{% load i18n %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | ||
<meta name="description" content=""> | ||
<meta name="author" content=""> | ||
<link rel="icon" href="../../favicon.ico"> | ||
|
||
<title>register/login</title> | ||
|
||
{% load static %} | ||
|
||
<!-- Bootstrap core CSS --> | ||
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet"> | ||
|
||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> | ||
<link href="{% static 'css/ie10-viewport-bug-workaround.css' %}" rel="stylesheet"> | ||
|
||
<!-- Custom styles for this template --> | ||
<link href="{% static 'css/signin.css' %}" rel="stylesheet"> | ||
|
||
<!-- Just for debugging purposes. Don't actually copy these 2 lines! --> | ||
<!--[if lt IE 9]><script src="{% static 'js/ie8-responsive-file-warning.js' %}"></script><![endif]--> | ||
<script src="{% static 'js/ie-emulation-modes-warning.js' %}"></script> | ||
|
||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> | ||
<!--[if lt IE 9]> | ||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> | ||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | ||
<![endif]--> | ||
</head> | ||
|
||
<body> | ||
|
||
<div class="container"> | ||
|
||
{# <div id="header">#} | ||
{# {% block header %}#} | ||
{# <a href="{% url 'index' %}">{% trans "Home" %}</a> |#} | ||
|
||
{% if user.is_authenticated %} | ||
{% trans "Logged in" %}: {{ user.username }} | ||
(<a href="{% url 'auth_logout' %}?next=/restaurantes/"></a> | | ||
<a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a>) | ||
{% else %} | ||
<a href="{% url 'auth_login' %}"></a> | ||
{% endif %} | ||
<hr /> | ||
{# {% endblock %}#} | ||
{# </div>#} | ||
|
||
{# <div id="content">#} | ||
{% block content %}{% endblock %} | ||
{# </div>#} | ||
|
||
</div> <!-- /container --> | ||
|
||
|
||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> | ||
<script src="{% static 'js/ie10-viewport-bug-workaround.js' %}"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% load i18n %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<link rel="stylesheet" href="{{ STATIC_URL }}style.css" /> | ||
<title>{% block title %}User test{% endblock %}</title> | ||
</head> | ||
|
||
<body> | ||
<div id="header"> | ||
{% block header %} | ||
<a href="{% url 'index' %}">{% trans "Home" %}</a> | | ||
|
||
{% if user.is_authenticated %} | ||
{% trans "Logged in" %}: {{ user.username }} | ||
(<a href="{% url 'auth_logout' %}?next=/restaurantes/"></a> | | ||
<a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a>) | ||
{% else %} | ||
<a href="{% url 'auth_login' %}">{% trans "Log in" %}</a> | ||
{% endif %} | ||
<hr /> | ||
{% endblock %} | ||
</div> | ||
|
||
<div id="content"> | ||
{% block content %}{% endblock %} | ||
</div> | ||
|
||
<div id="footer"> | ||
{% block footer %} | ||
<hr /> | ||
{% endblock %} | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Practica7/sitio_web/restaurantes/templates/registration/login.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
|
||
<form class="form-signin" role="form" method="post" action="."> | ||
{% csrf_token %} | ||
|
||
<h2 class="form-signin-heading">Please sign in</h2> | ||
<input class="form-control" placeholder="Username" id="id_username" maxlength="254" name="username" type="text" required autofocus=""/> | ||
<input type="password" class="form-control" placeholder="Password" id="id_password" name="password" required /> | ||
|
||
<button class="btn btn-lg btn-primary btn-block" type="submit" value="Submit" >Sign in</button> | ||
</form> | ||
|
||
{% endblock %} |
6 changes: 6 additions & 0 deletions
6
Practica7/sitio_web/restaurantes/templates/registration/logout.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Logged Out</h1> | ||
<p>You are now logged out.</p> | ||
{% endblock %} |
6 changes: 6 additions & 0 deletions
6
Practica7/sitio_web/restaurantes/templates/registration/registration_complete.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Registration Complete</h1> | ||
<p>You are now registered</p> | ||
{% endblock %} |
11 changes: 11 additions & 0 deletions
11
Practica7/sitio_web/restaurantes/templates/registration/registration_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>Register Here</h1> | ||
<form method="post" action="."> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
|
||
<input type="submit" value="Submit" /> | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.