-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spike for elections app and 3rd party apps
- Loading branch information
Pedro Burón
committed
Nov 9, 2011
1 parent
ced0aef
commit 361ac88
Showing
18 changed files
with
193 additions
and
8 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.contrib import admin | ||
|
||
from models import Election, Candidate | ||
|
||
class CandidateAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'created_at',) | ||
list_filter = ('last_name',) | ||
date_hierarchy = 'created_at' | ||
|
||
admin.site.register(Election) | ||
admin.site.register(Candidate, CandidateAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
class Election(models.Model): | ||
name = models.CharField(max_length=255) | ||
slug = models.SlugField() | ||
owner = models.ForeignKey('auth.User') | ||
|
||
created_at = models.DateTimeField(auto_now_add=True, editable=False) | ||
updated_at = models.DateTimeField(auto_now=True, editable=False) | ||
|
||
|
||
def __unicode__(self): | ||
return u"%s" % self.name | ||
|
||
|
||
class Candidate(models.Model): | ||
first_name = models.CharField(max_length=255) | ||
last_name = models.CharField(max_length=255) | ||
slug = models.SlugField() | ||
election = models.ForeignKey('Election') | ||
|
||
created_at = models.DateTimeField(auto_now_add=True, editable=False) | ||
updated_at = models.DateTimeField(auto_now=True, editable=False) | ||
|
||
@property | ||
def name(self): | ||
return u"%(first_name)s %(last_name)s" % { | ||
'first_name': self.first_name, | ||
'last_name': self.last_name | ||
} | ||
|
||
def __unicode__(self): | ||
return self.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
|
||
<title>{% block title%}Candidator{% endblock title %}</title> | ||
<body> | ||
|
||
{% block content %} | ||
{% endblock content %} | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "elections/base.html" %} | ||
|
||
{% block title %} | ||
{{ block.super }} Election | ||
{% endblock title %} | ||
|
||
{% block content %} | ||
<a href="{% url election_detail pk=object.pk %}">permalink {{ election.name }}</a> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "elections/base.html" %} | ||
|
||
{% block content %} | ||
<ul> | ||
{% for election in object_list %} | ||
<li>{{ election }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
This file demonstrates writing tests using the unittest module. These will pass | ||
when you run "manage.py test". | ||
Replace this 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.assertEqual(1 + 1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.conf.urls.defaults import patterns, url | ||
from django.views.generic import DetailView, ListView | ||
|
||
from models import Election | ||
|
||
urlpatterns = patterns('', | ||
url(r'^election/(?P<pk>\d+)/$', DetailView.as_view(model=Election), name='election_detail'), | ||
url(r'^$', ListView.as_view(model=Election), name='election_list'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Create your views here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
Django==1.3 | ||
South==0.7.3 | ||
distribute==0.6.19 | ||
django-debug-toolbar==0.8.5 | ||
django-grappelli==2.3.5 | ||
wsgiref==0.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
# ('Your Name', '[email protected]'), | ||
) | ||
|
||
INTERNAL_IPS = ('127.0.0.1',) | ||
|
||
MANAGERS = ADMINS | ||
|
||
DATABASES = { | ||
|
@@ -30,7 +32,7 @@ | |
# timezone as the operating system. | ||
# If running in a Windows environment this must be set to the same as your | ||
# system time zone. | ||
TIME_ZONE = 'America/Chicago' | ||
TIME_ZONE = 'America/Santiago' | ||
|
||
# Language code for this installation. All choices can be found here: | ||
# http://www.i18nguy.com/unicode/language-identifiers.html | ||
|
@@ -68,7 +70,7 @@ | |
# URL prefix for admin static files -- CSS, JavaScript and images. | ||
# Make sure to use a trailing slash. | ||
# Examples: "http://foo.com/static/admin/", "/static/admin/". | ||
ADMIN_MEDIA_PREFIX = '/static/admin/' | ||
ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/" | ||
|
||
# Additional locations of static files | ||
STATICFILES_DIRS = ( | ||
|
@@ -106,6 +108,7 @@ | |
ROOT_URLCONF = 'candidator.urls' | ||
|
||
TEMPLATE_DIRS = ( | ||
os.path.join(PROJECT_ROOT, 'templates'), | ||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | ||
# Always use forward slashes, even on Windows. | ||
# Don't forget to use absolute paths, not relative paths. | ||
|
@@ -119,9 +122,14 @@ | |
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
# Uncomment the next line to enable the admin: | ||
# 'django.contrib.admin', | ||
'grappelli', | ||
'django.contrib.admin', | ||
# Uncomment the next line to enable admin documentation: | ||
# 'django.contrib.admindocs', | ||
'django.contrib.admindocs', | ||
'debug_toolbar', | ||
'profiles', | ||
'smart_profile', | ||
'elections', | ||
) | ||
|
||
# A sample logging configuration. The only tangible logging | ||
|
@@ -146,3 +154,22 @@ | |
}, | ||
} | ||
} | ||
|
||
DEBUG_TOOLBAR_PANELS = ( | ||
'debug_toolbar.panels.version.VersionDebugPanel', | ||
'debug_toolbar.panels.timer.TimerDebugPanel', | ||
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel', | ||
'debug_toolbar.panels.headers.HeaderDebugPanel', | ||
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel', | ||
'debug_toolbar.panels.template.TemplateDebugPanel', | ||
'debug_toolbar.panels.sql.SQLDebugPanel', | ||
'debug_toolbar.panels.signals.SignalDebugPanel', | ||
'debug_toolbar.panels.logger.LoggingPanel', | ||
) | ||
|
||
DEBUG_TOOLBAR_CONFIG = { | ||
'INTERCEPT_REDIRECTS': False, | ||
'HIDE_DJANGO_SQL': False, | ||
} | ||
|
||
AUTH_PROFILE_MODULE = 'smart_profile.Profile' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from django.contrib import admin | ||
from models import Profile | ||
|
||
admin.site.register(Profile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import User | ||
from django.db.models.signals import post_save | ||
|
||
# Create your models here. | ||
|
||
class Profile(models.Model): | ||
name = models.CharField(max_length=255) | ||
biography = models.TextField() | ||
|
||
user = models.ForeignKey('auth.User') | ||
|
||
@models.permalink | ||
def get_absolute_url(self): | ||
return ('profiles_profile_detail', (), { 'username': self.user.username }) | ||
|
||
|
||
def create_user_profile(sender, instance, created, **kwargs): | ||
if created: | ||
Profile.objects.create(user=instance) | ||
|
||
post_save.connect(create_user_profile, sender=User) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
This file demonstrates writing tests using the unittest module. These will pass | ||
when you run "manage.py test". | ||
Replace this 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.assertEqual(1 + 1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Create your views here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<body> | ||
|
||
<body> | ||
{% for profile in object_list %} | ||
<li><a href="{{ profile.get_absolute_url }}">{{ profile.user.username }}</a></li> | ||
{% empty %} | ||
<li>No hay usuarios</li> | ||
{% endfor %} | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
from django.conf.urls.defaults import patterns, include, url | ||
|
||
# Uncomment the next two lines to enable the admin: | ||
# from django.contrib import admin | ||
# admin.autodiscover() | ||
from django.contrib import admin | ||
admin.autodiscover() | ||
|
||
urlpatterns = patterns('', | ||
# Examples: | ||
# url(r'^$', 'candidator.views.home', name='home'), | ||
# url(r'^candidator/', include('candidator.foo.urls')), | ||
|
||
# Uncomment the admin/doc line below to enable admin documentation: | ||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')), | ||
url(r'^admin/doc/', include('django.contrib.admindocs.urls')), | ||
|
||
# Uncomment the next line to enable the admin: | ||
# url(r'^admin/', include(admin.site.urls)), | ||
(r'^grappelli/', include('grappelli.urls')), | ||
url(r'^admin/', include(admin.site.urls)), | ||
|
||
(r'^profiles/', include('profiles.urls')), | ||
|
||
url(r'^elections/', include('elections.urls')), | ||
) |