Commit 2723f74d authored by Daniel W Bond's avatar Daniel W Bond
Browse files

removed commented-out address model from housing.models and put in separate...

removed commented-out address model from housing.models and put in separate directory along with other address material
parent 5a5a5681
<div class="form-group">
<label class="col-md-2">Address</label>
<div class="col-md-10">
<input type="text" class="form-control" placeholder="4400 University Drive">
</div>
</div>
<div class="form-group">
<label class="col-md-2">City</label>
<div class="col-md-4">
<input type="text" class="form-control" placeholder="Fairfax">
</div>
<label class="col-md-2">State</label>
<div class="col-md-4">
<select id="state" name="state">
{% for state in states %}
{% if user.student.address.state == state.0 %}
<option value="{{ state.0 }}" selected="selected">{{ state.1 }}</option>
{% else %}
{% if state.0 == "VA" %}
<option value="{{ state.0 }}" selected="selected">{{ state.1 }}</option>
{% else %}
<option value="{{ state.0 }}">{{ state.1 }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2">Zip Code</label>
<div class="col-md-1">
<input type="text" placeholder="22030">
</div>
</div>
# standard library imports
from __future__ import absolute_import, print_function
# core django imports
from django import forms
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string
from localflavor.us.us_states import US_STATES as states
# imports from your apps
#class YesNoBooleanWidget(forms.widget.RadioWidget):
class AddressWidget(forms.widgets.Widget):
template_name = 'address_widget.html'
def __init__(self, user=None, attrs=None):
super(AddressWidget, self).__init__(attrs)
def render(self, name, value, attrs=None):
# I'm sure I should be elated about i18n, but not feeling that way at the moment
actual_strings = [(abbr, unicode(state_name)) for abbr, state_name in states]
context = {
'states': actual_strings,
}
return mark_safe(render_to_string(self.template_name, context))
class AddressField(forms.CharField):
widget = AddressWidget
from localflavor.us.models import USStateField, USZipCodeField
# buildings on campus don't have separate addresses yet
class Address(TimeStampedModel):
street = models.CharField(max_length=120)
city = models.CharField(max_length=120)
state = USStateField()
zip_code = USZipCodeField()
class Meta:
verbose_name_plural = 'addresses'
def __str__(self): # __unicode__ on Python 2
return ', '.join(self.street, self.city, self.state)
......@@ -103,18 +103,3 @@ class Room(TimeStampedModel):
class Meta:
ordering = ['number']
# buildings on campus don't have separate addresses yet
#class Address(TimeStampedModel):
# street = models.CharField(max_length=120)
# city = models.CharField(max_length=120)
# state = USStateField()
# zip_code = models.IntegerField(max_length=5)
# class Meta:
# verbose_name_plural = 'addresses'
# def __str__(self): # __unicode__ on Python 2
# return self.street
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