Skip to content

Commit

Permalink
Location+page search, favorite add and delete
Browse files Browse the repository at this point in the history
  • Loading branch information
sanketnavin committed Sep 27, 2016
1 parent 1d05307 commit adce94b
Show file tree
Hide file tree
Showing 51 changed files with 1,160 additions and 244 deletions.
500 changes: 357 additions & 143 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file modified db.sqlite3
Binary file not shown.
20 changes: 18 additions & 2 deletions home/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@


class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput)
password1 = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'}))
password2 = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'}))

class Meta:
model = User
fields = ['username', 'email', 'password']
fields = ['username', 'email', 'password1', 'password2']

def __init__(self, *args, **kwargs):
super(UserForm, self).__init__(*args, **kwargs)
self.fields['username'].widget.attrs.update({'class': 'form-control'})
self.fields['email'].widget.attrs.update({'class': 'form-control'})

def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')

if not password2:
raise forms.ValidationError("You must confirm your password")
if password1 != password2:
raise forms.ValidationError("Your passwords do not match")
return password2
Binary file modified home/forms.pyc
Binary file not shown.
28 changes: 28 additions & 0 deletions home/static/home/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

var RestaurantListPage = {
init: function() {
this.$container = $('.resto-container');
this.bindEvents();
},


bindEvents: function() {
$('.btn-favorite', this.$container).on('click', function(e) {
e.preventDefault();

var self = $(this);
var url = $(this).attr('href');
$.getJSON(url, function(result) {
if (result.success) {
$('.glyphicon-bookmark', self).toggleClass('active');
}
});

return false;
});
}
};

$(document).ready(function() {
RestaurantListPage.init();
});
9 changes: 9 additions & 0 deletions home/static/home/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@
#grocerycard {
background: url('images/grocery.jpg') center / cover;
}

.glyphicon-bookmark {
color: #CCCCCC;
font-size: 16px;
}

.glyphicon-bookmark.active {
color: #FDB230;
}
10 changes: 8 additions & 2 deletions home/templates/home/base_logged_in.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="{% static 'home/main.js' %}"></script>

<link rel="stylesheet" type="text/css" href="{% static 'home/styles.css' %}" />

Expand All @@ -27,12 +28,18 @@
<a href="{% url 'home:index' %}" class="mdl-button mdl-color-text--white">
Home
</a>
<form class="navbar-form navbar-left" role="search" method="get" action="{% block search %}{% endblock %}">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search Here..." name="q" value="{{ request.GET.q }}">
</div>
<button type="submit" class="btn btn-default">Search</button>
</form>

<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation -->
<nav class="mdl-navigation">
<a href="" class="mdl-button mdl-color-text--white">
<a href="{% url 'home:favorites' %}" class="mdl-button mdl-color-text--white">
<i class="material-icons">bookmark</i>
Favorites
</a>
Expand Down Expand Up @@ -92,7 +99,6 @@ <h4 class="modal-title">Log In</h4>

<main class="mdl-layout__content">
<br>
<br>

{% block body %}

Expand Down
8 changes: 6 additions & 2 deletions home/templates/home/base_visitor.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<a href="{% url 'home:index' %}" class="mdl-button mdl-color-text--white">
Home
</a>
<form class="navbar-form navbar-left" role="search" method="get" action="{% block search %}{% endblock %}">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search Here..." name="q" value="{{ request.GET.q }}">
</div>
<button type="submit" class="btn btn-default">Search</button>
</form>

<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
Expand Down Expand Up @@ -91,8 +97,6 @@ <h4 class="modal-title">Log In</h4>

<main class="mdl-layout__content">
<br>
<br>
<br>

{% block body %}

Expand Down
91 changes: 91 additions & 0 deletions home/templates/home/favorites.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{% extends 'home/base_logged_in.html' %}

{% block body %}

<div class="container-fluid resto-container">

{% if restaurants %}
<!-- Houses -->
<div class="row">
{% for rest in restaurants %}
<div class="col-sm-6 col-lg-3">
<div class="thumbnail">
<a href="#">
<img src="{{ rest.restaurant_thumb }}" style="height:200px;width:300px;">
</a>
<div class="caption">
<h4>{{ rest.restaurant_name }}</h4>
<h6>{{ rest.restaurant_cuisine }}</h6>
<h6>{{ rest.restaurant_avgcostfor2 }}</h6>
<h4>{{ rest.user_rating_agg }}</h4>

<!-- View Details -->
<a href="#" class="btn btn-danger btn-sm" role="button">
View Details
</a>

<!-- Delete Album -->
<form action="{% url 'restaurants:delete_rest' rest.id %}" method="post" style="display: inline;">
{% csrf_token %}
<input type="hidden" name="rest_id" value="{{ rest.id }}" />
<button type="submit" class="btn btn-default btn-sm">
<span class="glyphicon glyphicon-trash"></span>
</button>
</form>

</div>
</div>
</div>
{% endfor %}
</div>

{% else %}
<h3>No Restaurants available</h3>

{% endif %}
</div>

<div class="container-fluid resto-container">

{% if houses %}
<!-- Houses -->
<div class="row">
{% for house in houses %}
<div class="col-sm-6 col-lg-3">
<div class="thumbnail">
<a href="{% url 'houseonrent:detail' house.id %}">
<img src="{{ house.house_pic }}" style="height:200px;width:300px;">
</a>
<div class="caption">
<h4>{{ house.house_title }}</h4>
<h6>{{ house.rent_price }}</h6>
<h4>{{ house.config }}</h4>

<!-- View Details -->
<a href=" {% url 'houseonrent:detail' house.id %}" class="btn btn-danger btn-sm" role="button">
View Details
</a>

<!-- Delete Album -->
<form action="{% url 'houseonrent:delete_house' house.id %}" method="post" style="display: inline;">
{% csrf_token %}
<input type="hidden" name="house_id" value="{{ house.id }}" />
<button type="submit" class="btn btn-default btn-sm">
<span class="glyphicon glyphicon-trash"></span>
</button>
</form>


</div>
</div>
</div>
{% endfor %}
</div>

{% else %}
<h3>No Houses available</h3>

{% endif %}
</div>

{% endblock %}
8 changes: 5 additions & 3 deletions home/templates/home/form_template.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{% for field in form %}
<div class="form-group">
<label class="control-label col-sm-2" for="ssstitle">{{ field.label_tag }}</label>
<div class="col-sm-10">{{ field }}</div>
<div class="col-sm-offset-2 col-sm-10">
<span class="text-danger small">{{ field.errors }}</span>
</div>
<label class="control-label col-sm-2" for="ssstitle">{{ field.label_tag }}</label>
<div class="col-sm-10">{{ field }}</div>
</div>
{% endfor %}
{% endfor %}

<!--|addclass:'form-control'-->
3 changes: 3 additions & 0 deletions home/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

{% block body %}

<br>
<br>

<div class="mdl-grid">
<div class="mdl-cell--1-offset mdl-cell-3-col">
<a href="{% url 'houseonrent:index' %}" style="text-decoration:none">
Expand Down
10 changes: 5 additions & 5 deletions home/templates/home/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<div class="row">
<div class="col-md-6">

<div class="panel panel-primary">
<div class="panel panel-default">

<div class="panel-heading">Sign Up</div>
<div class="panel-heading">Log In</div>

<div class="panel-body">
{% if error_message %}
Expand All @@ -22,15 +22,15 @@
Username:
</label>
<div class="col-sm-10">
<input id="id_username" maxlength="30" name="username" type="text">
<input class="form-control" id="id_username" maxlength="30" name="username" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="id_password">
Password:
</label>
<div class="col-sm-10">
<input id="id_password" maxlength="30" name="password" type="password">
<input class="form-control" id="id_password" maxlength="30" name="password" type="password">
</div>
</div>
<div class="form-group">
Expand All @@ -42,7 +42,7 @@
</div>

<div class="panel-footer">
<a href="#">Sign Up</a> &nbsp;
<a href="{% url 'home:register' %}">Sign Up</a> &nbsp;
<a href="#">Forgot Password?</a>
</div>

Expand Down
5 changes: 2 additions & 3 deletions home/templates/home/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="row">
<div class="col-md-6">

<div class="panel panel-info">
<div class="panel panel-default">

<div class="panel-heading">Sign Up</div>

Expand All @@ -27,8 +27,7 @@
</div>

<div class="panel-footer">
<a href="#">Sign Up</a> &nbsp;
<a href="#">Forgot Password?</a>
<a href="{% url 'home:login_user' %}">Login</a> &nbsp;
</div>

</div>
Expand Down
2 changes: 1 addition & 1 deletion home/templates/houseonrent/detail.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h3>
Square Feet : {{ house.sqft_area }}
Square Feet : {{ house.address }}
</h3>

42 changes: 34 additions & 8 deletions home/templates/houseonrent/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
{% extends base_template %}

{% block search %}
{% url 'houseonrent:search' %}
{% endblock %}

{% block body %}

<div class="container-fluid">
<div class="container">
<div class="row">
<div class="col-md-6">

<form class="navbar-form" action="{% url 'houseonrent:index' %}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group">
{{ form.location }}
</div>
&nbsp; &nbsp;
<input type="submit" class="btn btn-default" value="Search"/>
</form>

</div>
</div>
</div>

<br>
<br>


<div class="container-fluid resto-container">

{% if houses %}
<!-- Houses -->
Expand All @@ -11,22 +36,23 @@
<div class="col-sm-6 col-lg-3">
<div class="thumbnail">
<a href="{% url 'houseonrent:detail' house.id %}">
<img src="{{ house.house_logo.url }}" style="height:200px;width:300px;">
<img src="{{ house.house_pic }}" style="height:200px;width:300px;">
</a>
<div class="caption">
<h4>{{ house.house_title }}</h4>
<h6>{{ house.size_bhk }}</h6>
<h6>{{ house.location }}</h6>
<h4>{{ house.rent_price }}</h4>
<h6>{{ house.rent_price }}</h6>
<h4>{{ house.config }}</h4>

<!-- View Details -->
<a href=" {% url 'houseonrent:detail' house.id %}" class="btn btn-danger btn-sm" role="button">
View Details
</a>

<a href="{% url 'houseonrent:bookmark_house' house.id %}" class="btn btn-default btn-sm" role="button">
<span class="glyphicon glyphicon-star"></span>
</a>
{% if user.is_authenticated %}
<a href="{% url 'houseonrent:bookmark_house' house.id %}" class="btn btn-default btn-sm btn-favorite" role="button">
<span class="glyphicon glyphicon-bookmark {% if house.is_bookmarked %}active{% endif %}"></span>
</a>
{% endif %}

</div>
</div>
Expand Down
Loading

0 comments on commit adce94b

Please sign in to comment.