Commits

Colin Copeland committed 4fc8450

add tax value, tax rate, and notes fields

Comments (0)

Files changed (6)

lib/copelco/apps/estate/migrations/0005_auto__add_field_house_tax_value__add_field_house_tax_rate.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'House.tax_value'
+        db.add_column('estate_house', 'tax_value', self.gf('django.db.models.fields.DecimalField')(default=0, max_digits=16, decimal_places=2), keep_default=False)
+
+        # Adding field 'House.tax_rate'
+        db.add_column('estate_house', 'tax_rate', self.gf('django.db.models.fields.DecimalField')(default=0, max_digits=8, decimal_places=2), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'House.tax_value'
+        db.delete_column('estate_house', 'tax_value')
+
+        # Deleting field 'House.tax_rate'
+        db.delete_column('estate_house', 'tax_rate')
+
+
+    models = {
+        'estate.house': {
+            'Meta': {'object_name': 'House', '_ormbases': ['estate.Location']},
+            'acres': ('django.db.models.fields.DecimalField', [], {'max_digits': '8', 'decimal_places': '2'}),
+            'listing_price': ('django.db.models.fields.DecimalField', [], {'max_digits': '16', 'decimal_places': '2'}),
+            'location_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['estate.Location']", 'unique': 'True', 'primary_key': 'True'}),
+            'num_bathrooms': ('django.db.models.fields.SmallIntegerField', [], {}),
+            'num_bedrooms': ('django.db.models.fields.SmallIntegerField', [], {}),
+            'places': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['estate.Place']", 'through': "orm['estate.PlaceDistance']", 'symmetrical': 'False'}),
+            'rank': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
+            'sqft': ('django.db.models.fields.SmallIntegerField', [], {}),
+            'tax_rate': ('django.db.models.fields.DecimalField', [], {'max_digits': '8', 'decimal_places': '2'}),
+            'tax_value': ('django.db.models.fields.DecimalField', [], {'max_digits': '16', 'decimal_places': '2'}),
+            'year_built': ('django.db.models.fields.SmallIntegerField', [], {})
+        },
+        'estate.location': {
+            'Meta': {'object_name': 'Location'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'coords': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'zipcode': ('django.db.models.fields.CharField', [], {'max_length': '16'})
+        },
+        'estate.photo': {
+            'Meta': {'object_name': 'Photo'},
+            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'house': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'photos'", 'to': "orm['estate.House']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+            'original_image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'})
+        },
+        'estate.place': {
+            'Meta': {'object_name': 'Place', '_ormbases': ['estate.Location']},
+            'location_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['estate.Location']", 'unique': 'True', 'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'estate.placedistance': {
+            'Meta': {'object_name': 'PlaceDistance'},
+            'distance': ('django.db.models.fields.DecimalField', [], {'max_digits': '8', 'decimal_places': '2'}),
+            'house': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['estate.House']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'place': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['estate.Place']"})
+        }
+    }
+
+    complete_apps = ['estate']

lib/copelco/apps/estate/migrations/0006_auto__add_field_house_notes.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'House.notes'
+        db.add_column('estate_house', 'notes', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'House.notes'
+        db.delete_column('estate_house', 'notes')
+
+
+    models = {
+        'estate.house': {
+            'Meta': {'object_name': 'House', '_ormbases': ['estate.Location']},
+            'acres': ('django.db.models.fields.DecimalField', [], {'max_digits': '8', 'decimal_places': '2'}),
+            'listing_price': ('django.db.models.fields.DecimalField', [], {'max_digits': '16', 'decimal_places': '2'}),
+            'location_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['estate.Location']", 'unique': 'True', 'primary_key': 'True'}),
+            'notes': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'num_bathrooms': ('django.db.models.fields.SmallIntegerField', [], {}),
+            'num_bedrooms': ('django.db.models.fields.SmallIntegerField', [], {}),
+            'places': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['estate.Place']", 'through': "orm['estate.PlaceDistance']", 'symmetrical': 'False'}),
+            'rank': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
+            'sqft': ('django.db.models.fields.SmallIntegerField', [], {}),
+            'tax_rate': ('django.db.models.fields.DecimalField', [], {'max_digits': '8', 'decimal_places': '2'}),
+            'tax_value': ('django.db.models.fields.DecimalField', [], {'max_digits': '16', 'decimal_places': '2'}),
+            'year_built': ('django.db.models.fields.SmallIntegerField', [], {})
+        },
+        'estate.location': {
+            'Meta': {'object_name': 'Location'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'coords': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'zipcode': ('django.db.models.fields.CharField', [], {'max_length': '16'})
+        },
+        'estate.photo': {
+            'Meta': {'object_name': 'Photo'},
+            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'house': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'photos'", 'to': "orm['estate.House']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+            'original_image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'})
+        },
+        'estate.place': {
+            'Meta': {'object_name': 'Place', '_ormbases': ['estate.Location']},
+            'location_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['estate.Location']", 'unique': 'True', 'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'estate.placedistance': {
+            'Meta': {'object_name': 'PlaceDistance'},
+            'distance': ('django.db.models.fields.DecimalField', [], {'max_digits': '8', 'decimal_places': '2'}),
+            'house': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['estate.House']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'place': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['estate.Place']"})
+        }
+    }
+
+    complete_apps = ['estate']

lib/copelco/apps/estate/models.py

 from django.db import models
 from django.conf import settings
 from django.core.exceptions import ValidationError
+from django.core.urlresolvers import reverse
 
 from googlemaps import GoogleMaps
 
 
     year_built = models.SmallIntegerField()
     listing_price = models.DecimalField(max_digits=16, decimal_places=2)
+    tax_value = models.DecimalField(max_digits=16, decimal_places=2)
+    tax_rate = models.DecimalField(max_digits=8, decimal_places=2)    
     sqft = models.SmallIntegerField('SqFt')
     acres = models.DecimalField(max_digits=8, decimal_places=2)    
     num_bedrooms = models.SmallIntegerField('Bedrooms')
     num_bathrooms = models.SmallIntegerField('Bathrooms')
     rank = models.SmallIntegerField(choices=RANK_CHOICES, default=1)
-    
+    notes = models.TextField(blank=True)
+
     places = models.ManyToManyField('Place', through='PlaceDistance')
 
+    def get_absolute_url(self):
+        return reverse('house-map')
+
 
 class Place(Location):
     name = models.CharField(max_length=128)

lib/copelco/apps/estate/static/css/estate.css

 
 #houses_wrapper {
     margin-top: 1em;
+    font-size: 14px;
 }
 
 #houses_wrapper table {

lib/copelco/apps/estate/static/js/estate.js

     tr.append($('<th>').text('Address'));
     tr.append($('<th>').text('Year Built'));
     tr.append($('<th>').text('Listing Price'));
+    tr.append($('<th>').text('Tax Value'));
+    tr.append($('<th>').text('Tax Rate'));
     tr.append($('<th>').text('SqFt'));
     tr.append($('<th>').text('Acres'));
     tr.append($('<th>').text('Bedrooms'));
                         ul.append($('<li>').text(d.place__name + ': ' + d.distance + 'mi'));
                     });
                     info.append(ul);
+                    info.append($('<p>').text(result.notes));
                     var photos = $('<div>');
                     $.each(result.photos, function(idx, p) {
                         var anchor = $('<a>').attr({'href': p.display,
             tr.append($('<td>').append(a));
             tr.append($('<td>').text(item.year_built));
             tr.append($('<td>').text(item.listing_price));
+            tr.append($('<td>').text(item.tax_value));
+            tr.append($('<td>').text(item.tax_rate));
             tr.append($('<td>').text(item.sqft));
             tr.append($('<td>').text(item.acres));
             tr.append($('<td>').text(item.num_bedrooms));

lib/copelco/apps/estate/views.py

 from django.utils import simplejson
 from django.http import HttpResponse
 from django.core import serializers
+from django.contrib.auth.decorators import login_required
 
 from BeautifulSoup import BeautifulSoup
 
 from copelco.apps.estate.forms import ImportForm
 
 
+@login_required
 def house_map(request):
     context = {}
     return render(request, 'estate/map.html', context)
 
 
+@login_required
 def markers(request):
     fields = ('address', 'coords', 'sqft', 'year_built', 'listing_price',
-              'acres', 'num_bathrooms', 'num_bedrooms', 'rank', 'id')
+              'acres', 'num_bathrooms', 'num_bedrooms', 'rank', 'id',
+              'tax_value', 'tax_rate')
     houses = list(House.objects.values(*fields))
     for house in houses:
         house['listing_price'] = str(house['listing_price'])
+        house['tax_value'] = str(house['tax_value'])
+        house['tax_rate'] = str(house['tax_rate'])
         house['acres'] = str(house['acres'])
     return HttpResponse(simplejson.dumps(houses), mimetype='application/json')
 
 
+@login_required
 def info(request):
     house = get_object_or_404(House, pk=request.GET.get('house_id'))
     distances = PlaceDistance.objects.filter(house=house)
         photos.append({'thumb': photo.thumbnail.url,
                        'display': photo.display.url})
     context = {'address': house.address, 'distances': distances,
-               'photos': photos}
+               'photos': photos, 'notes': house.notes}
     return HttpResponse(simplejson.dumps(context), mimetype='application/json')
 
 
+@login_required
 def import_house(request):
     form = ImportForm(request.POST or None)
     if form.is_valid():
         print soup
     context = {'form': form}
     return render(request, 'estate/import.html', context)
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.