Skip to content

Commit

Permalink
Add photos to house page (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
putnik committed Mar 20, 2012
1 parent 6b0f5e9 commit ceea3db
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions house/models.py
Expand Up @@ -133,6 +133,7 @@ def make_upload_folder(instance, filename):
house = models.ForeignKey('House', verbose_name=_("House"))
file = YFField(upload_to=make_upload_folder)
title = models.CharField(max_length=250, blank=True, verbose_name=_("Title"))
author = models.CharField(max_length=250, blank=True, verbose_name=_("Author"))

def __unicode__(self):
return self.title
Expand Down
4 changes: 3 additions & 1 deletion house/views.py
Expand Up @@ -3,7 +3,7 @@
from django.template import RequestContext
from django.conf import settings
from django.db.models import Count, Max, Min
from house.models import Street, House
from house.models import *


def index_page(request):
Expand Down Expand Up @@ -36,9 +36,11 @@ def street(request, id):

def house(request, id):
h = House.objects.get(pk=id)
photo = HousePhoto.objects.filter(house=h)

return render_to_response('house/house.html', {
'house': h,
'photo': photo,
'is_admin': True,
'CMADE_KEY': settings.CMADE_KEY,
}, context_instance=RequestContext(request))
Expand Down
5 changes: 5 additions & 0 deletions static_base/css/content.css
Expand Up @@ -28,6 +28,11 @@ table.info {
width: 100%;
}

table.info.photo {
text-align: center;
margin-top: -1px;
}

.info th {
text-align: right;
}
Expand Down
11 changes: 11 additions & 0 deletions templates/house/house.html
Expand Up @@ -122,4 +122,15 @@ <h1><a href="/street/{{ house.street.id }}">{{ house.street }}</a>, {{ house.num
</tr>
{% endif %}
</table>

{% if house.kult_id %}
<table class="info photo">
{% for p in photo %}
<tr class="{% cycle 'even' 'odd' %}"><td>
<a href="{{ p.file.src }}" title="Автор: {{ p.author }}" target="_blank"><img src="{{ p.file.src_300 }}" alt="Автор: {{ p.author }}" /></a>
</td></tr>
{% endfor %}
</table>
{% endif %}

{% endblock %}

0 comments on commit ceea3db

Please sign in to comment.