Skip to content

Commit

Permalink
Added widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Roi Ronn committed Aug 16, 2011
1 parent 9d9f089 commit 374623c
Show file tree
Hide file tree
Showing 23 changed files with 649 additions and 49 deletions.
47 changes: 38 additions & 9 deletions backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,44 @@

####################Defines extended user class###################
class RentReport(models.Model):
city=models.CharField(max_length=20,blank=False,null=False)
street=models.CharField(max_length=20,blank=False,null=False)
address=models.CharField(max_length=5,blank=False,null=False)
apartment=models.CharField(max_length=5,blank=False,null=False)
old_price=models.IntegerField(blank=False,null=True)
new_price=models.IntegerField(blank=False,null=True)
price_up=models.BooleanField(blank=False,null=False)
lng=models.FloatField(null=True)
lat=models.FloatField(null=True)
city = models.CharField( max_length = 20, blank = False, null = False )
street = models.CharField( max_length = 20, blank = False, null = False )
address = models.CharField( max_length = 5, blank = False, null = False )
apartment = models.CharField( max_length = 5, blank = False, null = False,default=0 )
old_price = models.IntegerField( blank = False, null = True )
new_price = models.IntegerField( blank = False, null = True )
price_up = models.BooleanField( blank = False, null = False )
num_of_rooms=models.IntegerField(default=0)
lng = models.FloatField( null = True )
lat = models.FloatField( null = True )


class MobileFullReport(models.Model):
address = models.CharField(max_length=100,blank=False,null=False)
number = models.IntegerField()
lon = models.FloatField()
lat = models.FloatField()
real_loc = models.BooleanField(default=True)

class SingleRank(models.Model):
is_boolean=models.BooleanField(default=False)
owner_report = models.ForeignKey(MobileFullReport)
id = models.IntegerField(default=0)
ranks_sum = models.IntegerField(default=0)
num_of_ranks = models.IntegerField(default=0)

def addRanking(self,rank):
self.num_of_ranks += 1
self.ranks_sum += rank

def getRank(self):
if self.is_boolean:
if self.ranks_sum >= self.num_of_ranks/2 :
return 1
else:
return 0
else:
return self.ranks_sum / self.num_of_ranks



Expand Down
4 changes: 3 additions & 1 deletion backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

urlpatterns = patterns('backend.views',
url(r'^addReport', 'addReport', name='addReport'),
url(r'^check', 'makeQuery', name='addReport'),
url(r'^check', 'makeQuery', name='addReport'),
url(r'^addmobile', 'update_mobile', name='update_mobile'),
url(r'^sync', 'get_sync_data', name='sync'),
)
23 changes: 16 additions & 7 deletions backend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
except ImportError:
import simplejson as json

UNSPECIFIED_APARTMENT=-1
UNSPECIFIED=0

def getGeoLocation(city,street,number):
'''g
Expand Down Expand Up @@ -45,16 +45,19 @@ def addReport(request):
i_apartment=request.POST.get('apartment')
i_oldPrice=request.POST.get('oldPrice')
i_newPrice=request.POST.get('newPrice')
i_rooms=request.POST.get('rooms')

if not i_apartment:
i_apartment=UNSPECIFIED_APARTMENT
i_apartment=UNSPECIFIED
if not i_rooms:
i_rooms=UNSPECIFIED
report, created=RentReport.objects.get_or_create(city=i_city,street=i_street,address=i_address,apartment=i_apartment)
if created:
report.old_price=int(i_oldPrice)
report.new_price=int(i_newPrice)
report.num_of_rooms=i_rooms
lat,lng=getGeoLocation(i_city,i_street,i_address)
if lat and lng:
logging.info("&&&&&^^^^^^^&&&&&")
report.lat=lat
report.lng=lng
if i_oldPrice<i_newPrice:
Expand All @@ -63,7 +66,9 @@ def addReport(request):
report.price_up=False
report.save()
else:
pass
report.new_price=int(i_newPrice)
if i_rooms!=UNSPECIFIED:
report.num_of_rooms=i_rooms
if request.POST.get('respHtml'):
return HttpResponse('Html will come here')
else:
Expand All @@ -78,18 +83,22 @@ def makeQuery(request):
reports=RentReport.objects.filter(city=i_city,street=i_street,address=i_address)
logging.info(reports)
if len(reports)==0:
logging.info("###NOT FOUND")
return HttpResponse("");
else:
uc=False
resp=""
for report in reports:
if report.apartment!=UNSPECIFIED_APARTMENT:
if report.apartment!=UNSPECIFIED:
resp=resp+str(report.apartment)+" "
else:
uc=True
if uc:
resp=resp+" -1"
logging.info("########"+resp)
return HttpResponse(resp)

def update_mobile(request):
logging.info("POST:"+str(request.POST))
return HttpResponse('ok')

def get_sync_data(request):
return HttpResponse(json.dumps(settings.CHECK_LIST))
Binary file added frontend/static/img/rent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/static/img/wheader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions frontend/static/js/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,27 @@ function createMarker(ll, popupContentHTML, closeBox, overflow) {
return marker
}

function addMarker(lng,lat,street,house,oldP,newP){
function addMarker(lng,lat,street,house,oldP,newP,apr,rooms){
var lonlat = new OpenLayers.LonLat(lng,lat).transform(
cord_google,
cord_map
);
text='<p style="text-align:right; font-size:11px; color:black;">'+street+" "+house+":<br>"+'שכ"ד עלה מ-';
text+=oldP+ " ל ";
text+=newP+'</p>';
if (apr==0){
apr='לא צויין';
}
if (rooms==0){
rooms=' לא צויין';
}
var text;
text="כתובת:";
text+=street+" "+house+" דירה: "+apr+"<br>";
text+="מספר חדרים:";
text+=rooms+"<br>";
text+=' שכ"ד עלה מ-';
text+=oldP;
text+=" ל-";
text+=newP;
text='<p style="text-align:right; font-size:11px; color:black;">'+text+'</p>';
marker = createMarker(lonlat,text,false,false);
radius_layer.addMarker(marker);
}
Expand Down
14 changes: 7 additions & 7 deletions frontend/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
lang="{% firstof LANGUAGE_CODE 'en' %}">
<head>
<title>דירומטר - נלחמים במחירי הדיור</title>
<meta name="viewport" content="width=100%, initial-scale=1">
<meta property="og:title" content="דירומטר - נלחמים במחירי הדיור"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://dirometer.empeeric.com"/>
Expand All @@ -24,11 +25,6 @@
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.13.custom.css" />
<style type="text/css">
body {
background-image:url('img/bg.jpg');
padding:0px 0px;
margin:0px 0px 0px 0px;
}
#all{
background-image:url('img/background.png');
float:right;
Expand All @@ -45,7 +41,7 @@
margin-bottom:30px;
}
b{
color:white;
color:inherit;
font-family:arial
}
h1{
Expand Down Expand Up @@ -75,6 +71,7 @@
}
#logo
{
border-style: none;
width:83px;
height:80px;
}
Expand Down Expand Up @@ -108,7 +105,9 @@
<body >
<div id="all">
<div id="header">
{% block head %}
<img id="header_img" src='img/header.png'>
{% endblock %}
</div>

<div class="columns">
Expand All @@ -124,12 +123,13 @@
{% endblock %}
<div id='main_col'>
{% block content %}{% endblock %}

{% block footer %}
<div id='footer'>
<a href="http://www.empeeric.com"> <img id="logo" src="img/logo.png" class="pointer"></a>
<span style="font-family:Arial; color:WHITE;" id="foorwe_text">נבנה ע"י אמפיריק ,</span>
<a href="javascript:showDialog( 'contact_us_dialog' )">צור קשר</a>
</div>
{% endblock %}
</div>

</div>
Expand Down
50 changes: 40 additions & 10 deletions frontend/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{% extends 'base.html' %}
{% block extra-css %}
<style type="text/css">
body {
background-image:url('img/bg.jpg');
padding:0px 0px;
margin:0px 0px 0px 0px;
}
#map{
width:600px;
height:450px;
Expand All @@ -14,8 +19,8 @@
}

.center{
position:relative;
left:-90px
position: relative;
left: -119px;
}
input{
width:240px;
Expand All @@ -42,12 +47,14 @@
.pointer{
cursor:pointer
}

.report_but
{
margin-right:30px;
}

.ui-dialog{
z-index: 1005;
}
.cu_input{
width:300px;
position:relative;
Expand Down Expand Up @@ -144,6 +151,14 @@ <h1>בעל הבית השתגע?</h1>
<td>
<input type="text" id="up_apr_in">
</td>
</tr>
<tr>
<td>
מספר חדרים:
</td>
<td>
<input type="text" id="up_rooms">
</td>
</tr>
<tr>
<td>
Expand All @@ -165,7 +180,7 @@ <h1>בעל הבית השתגע?</h1>
<br>
<br>
<div class="error" style="color:RED;"></div>
<img src="img/submit_button.png" class="pointer" onclick="submit_new_rent()"/>
<img src="img/submit_button.png" class="pointer center" onclick="submit_new_rent()"/>
</div>

<div id='rent_down_dialog'>
Expand Down Expand Up @@ -206,6 +221,14 @@ <h1>בעל הבית השתגע?</h1>
</tr>
<tr>
<td>
מספר חדרים:
</td>
<td>
<input type="text" id="down_rooms">
</td>
</tr>
<tr>
<td>
שכ"ד ישן:
</td>
<td>
Expand Down Expand Up @@ -343,6 +366,7 @@ <h1>בעל הבית השתגע?</h1>
var house=$('#up_house_in').val();
var old=$('#up_old_in').val();
var newP=$('#up_new_in').val();
var rooms=$('#up_rooms').val();
if (city==""||street==""||house==""||old==""||newP==""){
$('.error').html("בכדי לדווח על דירה יש צורך בשם העיר, הרחוב והבניין")
}else{
Expand All @@ -354,7 +378,8 @@ <h1>בעל הבית השתגע?</h1>
"&address="+house+
"&apartment="+apr+
"&oldPrice="+old+
"&newPrice="+newP,
"&newPrice="+newP+
"&rooms="+rooms,
success: function(data) {
closeAll();
window.location.reload();
Expand All @@ -375,6 +400,7 @@ <h1>בעל הבית השתגע?</h1>
var house=$('#down_house_in').val();
var old=$('#down_old_in').val();
var newP=$('#down_new_in').val();
var rooms=$('#down_rooms').val();
if (city==""||street==""||house==""||old==""||newP==""){
$('.error').html("בכדי לדווח על דירה יש צורך בשם העיר, הרחוב והבניין")
}else{
Expand Down Expand Up @@ -457,26 +483,30 @@ <h1>בעל הבית השתגע?</h1>
$('#rent_up_dialog').dialog({
autoOpen: false,
// dialogClass: 'alert',
width:580
width:580,
zIndex:1005
});
$('#rent_down_dialog').dialog({
autoOpen: false,
// dialogClass: 'alert',
width:580
width:580,
zIndex:1006
});
$('#check_dialog').dialog({
autoOpen: false,
// dialogClass: 'alert',
width:570
width:570,
zIndex:1007
});
$('#contact_us_dialog').dialog({
autoOpen: false,
// dialogClass: 'alert',
width:580
width:580,
zIndex:1008
});
{% for r in BAD_LIST%}

addMarker( {{r.lng}} , {{r.lat}} ,'{{r.street}}','{{r.address}}', '{{r.old_price}}' ,'{{r.new_price}}');
addMarker( {{r.lng}} , {{r.lat}} ,'{{r.street}}','{{r.address}}', '{{r.old_price}}' ,'{{r.new_price}}',{{ r.apartment }},{{ r.num_of_rooms }});

{%endfor%}

Expand Down
10 changes: 10 additions & 0 deletions frontend/templates/testFrame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body style="background-color: #fafad2;">
<iframe src="http://localhost:8080/widget" style="width: 299px;;height: 505px;" scrolling="no"></iframe>
</body>
</html>
Loading

0 comments on commit 374623c

Please sign in to comment.