front page admin + slider

This commit is contained in:
Sanj 2011-08-01 19:19:19 +05:30
parent 6498ac90f7
commit cb96e0a20f
10 changed files with 166 additions and 4 deletions

View File

21
itf/frontpage/admin.py Normal file
View File

@ -0,0 +1,21 @@
from django.contrib import admin
from models import *
# from forms import ArticleForm
class MenuItemInline(admin.StackedInline):
model = MenuItem
extra = 7
class SliderBoxAdmin(admin.ModelAdmin):
list_display = ('title', 'order',)
list_editable = ['order']
# list_display = ('title', 'date',)
class MenuHeadingAdmin(admin.ModelAdmin):
inlines = [MenuItemInline]
list_display = ('name', 'order',)
list_editable = ['order']
admin.site.register(MenuHeading, MenuHeadingAdmin)
admin.site.register(SliderBox, SliderBoxAdmin)

44
itf/frontpage/models.py Normal file
View File

@ -0,0 +1,44 @@
from django.db import models
class SliderBox(models.Model):
title = models.CharField(max_length=64)
image = models.ImageField(upload_to='upload/sliderImages/')
boldText = models.CharField(max_length=256, blank=True)
normalText = models.CharField(max_length=256, blank=True)
url = models.CharField(max_length=128, blank=True)
order = models.IntegerField(default=1)
imageTop = models.IntegerField(default=0)
is_displayed = models.BooleanField(default=True)
def __unicode__(self):
return self.title
class Meta:
ordering = ['order', 'id']
class MenuHeading(models.Model):
name = models.CharField(max_length=64)
order = models.IntegerField(default=1)
def __unicode__(self):
return self.name
class Meta:
ordering = ['order', 'id']
class MenuItem(models.Model):
name = models.CharField(max_length=64)
url = models.CharField(max_length=256)
menu = models.ForeignKey(MenuHeading)
order = models.IntegerField(default=1)
def __unicode__(self):
return self.name
class Meta:
ordering = ['order', 'id']
# Create your models here.

23
itf/frontpage/tests.py Normal file
View File

@ -0,0 +1,23 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

27
itf/frontpage/views.py Normal file
View File

@ -0,0 +1,27 @@
# Create your views here.
from django.shortcuts import render_to_response
from models import *
from settings import TWITTER_ID
import twitter
def index(request):
tApi = twitter.Api()
statuses = tApi.GetUserTimeline(TWITTER_ID)
boxes = SliderBox.objects.all()
menuHeads = MenuHeading.objects.all()
menus = []
for m in menuHeads:
d = {
'name': m.name,
'items': [{'name': item.name, 'url': item.url} for item in m.menuitem_set.all()]
}
menus.append(d)
return render_to_response("noel/index.html", {
'tweets': statuses[0:5],
'boxes': boxes,
'menus': menus
})

View File

@ -38,6 +38,8 @@ DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
TWITTER_ID = "sachin_rt"
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
@ -142,6 +144,7 @@ INSTALLED_APPS = (
'app',
'api',
'boxes',
'frontpage',
# 'solango',
'multilingual',
# 'multilingual.flatpages',

View File

@ -74,6 +74,7 @@ opacity:0.6;}
height:282px;
background-color:#FFF;
position:relative;
background-repeat: no-repeat;
-moz-border-radius:8px;
-webkit-border-radius:8px;
border-radius:8px;
@ -171,7 +172,7 @@ clear:both;
margin-left:auto;
margin-right:auto;
padding-top:37px;
overflow-y:hidden;
overflow:hidden;
clear:both;
position:relative;}
@ -189,7 +190,10 @@ right:10px;}
#sliderTabs /*at 800 res, we have different probs in different browsers with the tabs, ok to give position absolute to the ul?*/
{width:4000px;}
{width:4000px;
position:absolute;
left:0px;
}
ul#sliderTabs li
{float:left;}

View File

@ -22,6 +22,16 @@
<a href=""><img src="/static/images/noel/home.png" width="16" height="17" alt="home" id="homeIcon"></a>
<ul id="navMenu">
{% for m in menus %}
<li><a href="">{{ m.name }}</a>
<ul>
{% for i in m.items %}
<li><a href="{{ i.url }}">{{ i.name }}</a></li>
{% endfor %}
</ul>
</li>
{% endfor %}
<!--
<li><a href="">Resources</a>
<ul>
<li><a href="">Script Archive</a></li>
@ -56,6 +66,7 @@
<li><a href="">Contribute to eRang</a></li>
</ul>
</li>
-->
</ul>
<ul id="loginMenu">
@ -69,6 +80,17 @@
{% endblock %}
<div id="footer">
{% for m in menus %}
<ul class="footerList">
<a href="">{{ m.name }}</a>
{% for i in m.items %}
<li><a href="{{ i.url }}">- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ i.name }}</a></li>
{% endfor %}
</ul>
{% endfor %}
<!--
<ul id="resources" class="footerList">
<a href="">Resources</a>
<li><a href="">- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Script Archive</a></li>
@ -102,7 +124,7 @@
<li><a href="">- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;volunteer</a></li>
<li><a href="">- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contribute to eRang</a></li>
</ul>
-->
<p id="copyright">&copy; 2011 India Theatre Forum. All Rights Reserved.</p>
</div>

View File

@ -4,7 +4,7 @@
{% block extra_head %}
<link rel="stylesheet" type="text/css" href="/static/css/noel/home.css" />
<script type="text/javascript" src="/static/js/frontpage.js"></script>
{% endblock %}
{% block content %}
@ -37,11 +37,16 @@
<div id="contentTab">
<ul>
{% for t in tweets %}
<li>{{ t.text }}</li>
{% endfor %}
<!--
<li>@dootah there's a new play this weekend. <span>bit.ly/xYr3dD</span></li>
<li>@dootah there's a new play this weekend. <span>bit.ly/xYr3dD</span></li>
<li>@dootah there's a new play this weekend. <span>bit.ly/xYr3dD</span></li>
<li>@dootah there's a new play this weekend. <span>bit.ly/xYr3dD</span></li>
<li>@dootah there's a new play this weekend. <span>bit.ly/xYr3dD</span></li>
-->
</ul>
</div>
@ -60,6 +65,17 @@
<img src="/static/images/noel/arrow-left.png" width="28" height="42" alt="arrow-left" id="arrowLeft">
<img src="/static/images/noel/arrow-right.png" width="28" height="42" alt="arrow-right" id="arrowRight">
<ul id="sliderTabs">
{% for b in boxes %}
<li class="tab" style="background-image:url('{{b.image.url}}');background-position:0px {{b.imageTop}}px;">
<h4 class="tabHeader">{{ b.title }}</h4>
<div class="textTab">
<p><span class="boldText">{{ b.boldText }}</span> {{ b.normalText }}</p>
</div>
<a href="{{ b.url }}" class="buttonTab"> Learn more </a>
</li>
{% endfor %}
<!--
<li id="scriptArchive" class="tab">
<h3 class="tabHeader"> SCRIPT <span>ARCHIVE</span> </h3>
<div class="textTab">
@ -108,6 +124,7 @@
<p><span>Unsure about a situation?</span> Need to know the best way to proceed? Here are some stories & guidelines to help you.</p>
</div>
<a href="" class="buttonTab"> Learn more </a> </li>
-->
</ul>
</div>
</div>

View File

@ -15,6 +15,7 @@ urlpatterns = patterns('',
# Example:
# (r'^bhangar/', include('bhangar.foo.urls')),
#(r'^search/', include('solango.urls')),
(r'^t/$', "frontpage.views.index"),
(r'^comments/', include('django.contrib.comments.urls')),
(r'^ckeditor/', include('ckeditor.urls')),
(r'^robots.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}),