Commit a2842c00 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

fixing urls

parent 96fb76e7
......@@ -3,6 +3,7 @@ from django.contrib.auth.models import User
from autoslug import AutoSlugField
from model_utils.models import TimeStampedModel
from django.core.validators import RegexValidator
from django.core.urlresolvers import reverse
class Student(TimeStampedModel):
user = models.OneToOneField(User)
......@@ -12,9 +13,9 @@ class Student(TimeStampedModel):
# rating = models.IntegerField(null=True,default=0)
slug = AutoSlugField(populate_from='user', unique=True)
# populate from user.username, no?
# needs a get_absolute_url ?
def get_absolute_url(self):
return reverse('profile', kwargs={'slug':self.slug})
def __unicode__(self):
return '%s' % self.user.username
......
......@@ -4,6 +4,7 @@ from core.models import Course
from django.conf import settings
from model_utils.models import TimeStampedModel
from autoslug import AutoSlugField
from randomslugfield import RandomSlugField
class Lookout(TimeStampedModel):
owner = models.ForeignKey(settings.AUTH_USER_MODEL)
......@@ -11,7 +12,8 @@ class Lookout(TimeStampedModel):
#course = models.ForeignKey('Course')
# place other possible fields here, ISBN and Course only for right now.
slug = AutoSlugField(populate_from='isbn', unique=True)
isbnslug = AutoSlugField(populate_from='isbn')
randomslug = RandomSlugField(length=6, exclude_upper=True)
# needs get_absolute_url
......
......@@ -31,21 +31,24 @@ TEMPLATE_CONTEXT_PROCESSORS = (
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
# apps
'trades',
'core',
'lookouts',
# packages
'randomslugfield',
'django_gravatar',
'crispy_forms',
'easy_thumbnails',
'haystack',
'piwik',
'django.contrib.admindocs',
)
CRISPY_TEMPLATE_PACK = 'bootstrap'
......
from lookouts.models import Lookout
from django.views.generic import TemplateView
class HomepageView(TemplateView):
template_name = 'index.html'
def get_context_data(self, **kwargs):
context = super(HomepageView, self).get_context_data(**kwargs)
context['my_lookouts'] = Lookout.objects.all()
return context
......@@ -89,11 +89,11 @@ SRCT Bookshare • Homepage
<div class="row">
<div class="col-sm-5 col-sm-offset-1">
<a href="{% url 'createListing' %}" class="btn btn-primary btn-lg btn-block">I <em>have</em> a book</a>
<a href="{% url 'create_listing' %}" class="btn btn-primary btn-lg btn-block">I <em>have</em> a book</a>
</div>
<div class="col-sm-5">
<a href="{% url 'all_listings' %}" class="btn btn-primary btn-lg btn-block">I <em>need</em> a book</a>
<a href="{% url 'list_listings' %}" class="btn btn-primary btn-lg btn-block">I <em>need</em> a book</a>
</div>
</div>
......
......@@ -13,8 +13,8 @@
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
{% if user.is_authenticated %}
<li><a href="{% url 'createListing' %}">Create Listing</a></li>
<li><a href="{% url 'all_listings' %}">Latest Listings</a></li>
<li><a href="{% url 'create_listing' %}">Create Listing</a></li>
<li><a href="{% url 'list_listings' %}">Latest Listings</a></li>
{% else %}
<li><a href="{% url 'about' %}">About</a></li>
{% endif %}
......
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