projects come from back-end

This commit is contained in:
Sanj 2011-10-05 16:02:26 +05:30
parent 1ceb88c052
commit ab313d2967
5 changed files with 78 additions and 12 deletions

View File

@ -7,6 +7,7 @@ PROJECT_ROOT = os.path.dirname(__file__)
LOCAL_DEVELOPMENT = True LOCAL_DEVELOPMENT = True
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
JSON_DEBUG = True
ADMINS = ( ADMINS = (
# ('Your Name', 'your_email@domain.com'), # ('Your Name', 'your_email@domain.com'),
@ -98,6 +99,7 @@ INSTALLED_APPS = (
'django.contrib.admin', 'django.contrib.admin',
'urb', 'urb',
'django_extensions', 'django_extensions',
'sorl.thumbnail',
# Uncomment the next line to enable the admin: # Uncomment the next line to enable the admin:
# 'django.contrib.admin', # 'django.contrib.admin',
# Uncomment the next line to enable admin documentation: # Uncomment the next line to enable admin documentation:

View File

@ -18,7 +18,31 @@
pause: 4000, pause: 4000,
hoverPause: true hoverPause: true
}); });
$('.projectThumb').click(function() {
// alert("hi");
var $this = $(this);
if ($this.hasClass("selected")) {
return false;
}
$('.selected').removeClass("selected");
$this.addClass("selected");
var project_id = $this.attr("data-id");
$.getJSON("project_json", {'id': project_id}, function(data) {
$('#projectTitle').next().text(data.title);
$('#projectSizeProgram').next().html(nl2br(data.size_program));
$('#projectDesignStatement').next().html(nl2br(data.design_statement));
$('#projectExtraText').next().html(nl2br(data.extra_text));
}); });
});
});
function nl2br(str) {
return str.replace("\n", "<br />");
}
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
@ -58,18 +82,18 @@
</div> </div>
<div id="textGallery"> <div id="textGallery">
<p class="orange">Project</p> <p class="orange" id="projectTitle">Project</p>
<p>Dummy text</p> <p>Dummy text</p>
<br> <br>
<p class="orange">Size & Program</p> <p class="orange" id="projectSizeProgram">Size & Program</p>
<p>Dummy text</p> <p>Dummy text</p>
<br> <br>
<p class="orange">Design Statement</p> <p class="orange" id="projectDesignStatement">Design Statement</p>
<p>Dummy text</p> <p>Dummy text</p>
<br> <br>
<!--
<p class="orange">Start Date ???</p> <p class="orange">Start Date ???</p>
<p>Dummy text</p> <p>Dummy text</p>
<br> <br>
@ -81,18 +105,25 @@
<p class="orange">Location ???</p> <p class="orange">Location ???</p>
<p>Dummy text</p> <p>Dummy text</p>
<br> <br>
-->
<p class="orange">Content Block ???</p> <p class="orange" id="projectExtraText">Content Block ???</p>
<p>Dummy text Dummy text Dummy text</p> <p>Dummy text Dummy text Dummy text</p>
<br> <br>
</div><!--TEXT GALLERY CLOSING--> </div><!--TEXT GALLERY CLOSING-->
<!--</div><!--PROJECT GALLERY CLOSING--> <!--</div> --><!--PROJECT GALLERY CLOSING-->
</div> </div>
<div class="clear"> <div class="clear">
</div><!--CLEAR CLOSING--> </div><!--CLEAR CLOSING-->
<ul id="scroller"><!-- logo jutting right on 1024 --> <ul id="scroller"><!-- logo jutting right on 1024 -->
{% load thumbnail %}
{% for p in projects %}
{% thumbnail p.thumb_image "100x100" crop="center" as im %}
<li><img src="{{ im.url }}" data-id="{{ p.id }}" width="100" height="100" class="projectThumb" /></li>
{% endthumbnail %}
{% endfor %}
<!--
<li><img src="/static/images/dummy1.jpg" width="100" height="100" class="selected"></li> <li><img src="/static/images/dummy1.jpg" width="100" height="100" class="selected"></li>
<li><img src="/static/images/dummy2.jpg" width="100" height="100" class="selected"></li> <li><img src="/static/images/dummy2.jpg" width="100" height="100" class="selected"></li>
<li><img src="/static/images/dummy3.jpg" width="100" height="100" class="selected"></li> <li><img src="/static/images/dummy3.jpg" width="100" height="100" class="selected"></li>
@ -111,8 +142,7 @@
<li><img src="/static/images/dummy4.jpg" width="100" height="100" class="selected"></li> <li><img src="/static/images/dummy4.jpg" width="100" height="100" class="selected"></li>
<li><img src="/static/images/dummy5.jpg" width="100" height="100" class="selected"></li> <li><img src="/static/images/dummy5.jpg" width="100" height="100" class="selected"></li>
<li><img src="/static/images/dummy1.jpg" width="100" height="100" class="selected"></li> <li><img src="/static/images/dummy1.jpg" width="100" height="100" class="selected"></li>
-->
</ul> </ul>
{% endblock %} {% endblock %}

View File

@ -16,6 +16,28 @@ class Project(models.Model):
# end_date = models.DateField(blank=True) # end_date = models.DateField(blank=True)
# location = models.CharField(max_length=255, blank=True) # location = models.CharField(max_length=255, blank=True)
def get_info(self):
return {
'id': self.id,
'title': self.title,
'slug': self.slug,
'thumb_image': self.thumb_image.url,
'size_program': self.size_program,
'design_statement': self.design_statement,
'extra_text': self.extra_text,
'images': self.get_images()
}
def get_images(self):
imgs = []
for i in self.projectimage_set.all():
imgs.append({
'url': i.image.url,
'caption': i.caption
})
return imgs
def __unicode__(self): def __unicode__(self):
return self.title return self.title

View File

@ -1,5 +1,8 @@
# Create your views here. # Create your views here.
from django.shortcuts import render_to_response from django.shortcuts import render_to_response, get_object_or_404
from models import *
import json
from ox.django.shortcuts import render_to_json_response
def home(request): def home(request):
return render_to_response("home.html", {}) return render_to_response("home.html", {})
@ -8,7 +11,15 @@ def profile(request):
return render_to_response("profile.html", {}) return render_to_response("profile.html", {})
def projects(request): def projects(request):
return render_to_response("projects.html", {}) return render_to_response("projects.html", {
'projects': Project.objects.all()
})
def project_json(request):
project_id = request.GET.get("id", "0")
project = get_object_or_404(Project, pk=project_id)
data = project.get_info()
return render_to_json_response(data)
def jobs(request): def jobs(request):
return render_to_response("jobs.html", {}) return render_to_response("jobs.html", {})

View File

@ -12,6 +12,7 @@ urlpatterns = patterns('',
(r'^home$', 'urb.views.home'), (r'^home$', 'urb.views.home'),
(r'^profile$', 'urb.views.profile'), (r'^profile$', 'urb.views.profile'),
(r'^projects$', 'urb.views.projects'), (r'^projects$', 'urb.views.projects'),
(r'^project_json$', 'urb.views.project_json'),
(r'^jobs$', 'urb.views.jobs'), (r'^jobs$', 'urb.views.jobs'),
(r'^contact$', 'urb.views.contact'), (r'^contact$', 'urb.views.contact'),
(r'^links$', 'urb.views.links'), (r'^links$', 'urb.views.links'),