diff --git a/pastebin/models.py b/pastebin/models.py index 93d0ba8..c3e1387 100644 --- a/pastebin/models.py +++ b/pastebin/models.py @@ -6,6 +6,7 @@ from hashlib import md5 from datetime import datetime, timedelta from django.contrib.auth.models import User +from django.core.urlresolvers import reverse from django.db import models vertex_pattern = re.compile(r'vertex\s+([0-9.e+-]+)\s+([0-9.e+-]+)\s+([0-9.e+-]+)') @@ -60,6 +61,13 @@ class Geometry(models.Model): file = models.FileField(upload_to=safe_upload_path('models')) sourcefile = models.FileField(upload_to=safe_upload_path('sources'), blank=True) + def get_absolute_url(self): + return reverse('geometry_details', kwargs={'id' : self.pk}) + + @classmethod + def get_latest(cls): + return cls.objects.all().filter(public = True).order_by('date')[:10] + def get_expiration_date(self): for expiration in [self.HOUR, self.DAY, self.WEEK, self.MONTH]: if self.expiration == expiration: diff --git a/pastebin/templates/pastebin/geometry_create.html b/pastebin/templates/pastebin/geometry_create.html index 9c296fa..bdd870e 100644 --- a/pastebin/templates/pastebin/geometry_create.html +++ b/pastebin/templates/pastebin/geometry_create.html @@ -57,8 +57,17 @@ $(document).ready(function() {
- -
+

Latest uploads

+ +
diff --git a/pastebin/views.py b/pastebin/views.py index 73eb926..0524133 100644 --- a/pastebin/views.py +++ b/pastebin/views.py @@ -1,6 +1,7 @@ from django.views.generic.edit import CreateView from django.views.generic.detail import DetailView from django.core.urlresolvers import reverse +from django.views.generic.base import ContextMixin from forms import GeometryForm from models import Geometry @@ -19,4 +20,9 @@ class GeometryCreate(CreateView): template_name = 'pastebin/geometry_create.html' def get_success_url(self): - return reverse('geometry_details', kwargs={'id' :self.object.id}) \ No newline at end of file + return reverse('geometry_details', kwargs={'id' :self.object.id}) + + def get_context_data(self, **kwargs): + context = super(CreateView, self).get_context_data(**kwargs) + context['latest_geometries'] = Geometry.get_latest() + return context \ No newline at end of file diff --git a/static_common/css/layout.css b/static_common/css/layout.css index 26f5caa..5d60e57 100644 --- a/static_common/css/layout.css +++ b/static_common/css/layout.css @@ -41,6 +41,10 @@ border-color: #eeeeee; border-radius: 3px; background-color: #eee; } + .textcontainer .uploads-list { + list-style: none; } + .textcontainer .uploads-list a { + text-decoration: none; } .textcontainer .pure-form label { font-weight: bold; border-bottom: 1px solid #ccc; } diff --git a/static_common/css/layout.scss b/static_common/css/layout.scss index bb9cdda..b2d2802 100644 --- a/static_common/css/layout.scss +++ b/static_common/css/layout.scss @@ -54,6 +54,14 @@ @include roundconers(#eee,6px); background-color: #eee; + .uploads-list { + list-style: none; + + a { + text-decoration: none; + } + } + .pure-form { label { font-weight: bold;