From 0cef00ca8f4827986fdf66ee56910a93f79e7a15 Mon Sep 17 00:00:00 2001 From: sebastian Date: Sat, 8 Feb 2014 17:52:33 +0100 Subject: [PATCH] Added public pastes list view Fixed css some more --- pastebin/forms.py | 6 +- .../templates/pastebin/geometry_list.html | 78 +++++++++++++++++++ pastebin/urls.py | 9 ++- pastebin/views.py | 10 ++- static_common/css/layout.css | 49 +++++++----- static_common/css/layout.scss | 35 +++++---- templates/base.html | 1 + templates/home.html | 6 +- 8 files changed, 148 insertions(+), 46 deletions(-) create mode 100644 pastebin/templates/pastebin/geometry_list.html diff --git a/pastebin/forms.py b/pastebin/forms.py index 917fd9d..f39b7e4 100644 --- a/pastebin/forms.py +++ b/pastebin/forms.py @@ -20,10 +20,8 @@ class STLUploadForm(ModelForm): stlfile = self.cleaned_data.get("file") stlfile.open() - print dir(stlfile) - if stlfile.read(5) != "solid": - print "binary" + #print "binary" #Skip header stlfile.seek(80) count = struct.unpack("i",stlfile.read(4))[0] @@ -31,7 +29,7 @@ class STLUploadForm(ModelForm): raise forms.ValidationError("Not a valid binary STL file.") else: - print "ascii" + #print "ascii" next_patterns = [facet_pattern] stlfile.readline() line = stlfile.readline().strip() diff --git a/pastebin/templates/pastebin/geometry_list.html b/pastebin/templates/pastebin/geometry_list.html new file mode 100644 index 0000000..81e3a22 --- /dev/null +++ b/pastebin/templates/pastebin/geometry_list.html @@ -0,0 +1,78 @@ +{% extends "base.html" %} + + +{% block title %} All public pastes{% endblock %} + + +{% block headeraddons %} + +{% endblock %} + + +{% block content %} +
+
+ +
+ +

All public pastes

+
+
+
+ + + + + + + + + + + + + {% for geometry in geometries %} + + + + + + + + + {% endfor %} +
NameUploaderSize (w x h x d)PolygonsExpiresDate
{{geometry.name}} + {% if geometry.user %} + {{geometry.user.username}} + {% else %} + Anonymous + {% endif %} + {{geometry.get_width}} x {{geometry.get_height}} x {{geometry.get_depth}}{{geometry.get_polycount}} + {% if geometry.get_expiration_date %} + {{ geometry.get_expiration_date|timeuntil}} + {% else %} + never + {% endif %} + {{geometry.date}}
+
+
+ {% if geometries.has_previous %} + previous... + {% endif %} + + {% if geometries.number %} + Page {{ geometries.number }} of {{ geometries.paginator.num_pages }} + {% endif %} + + {% if geometries.has_next %} + ..next + {% endif %} +
+
+
+ {% include 'pastebin/latest_geometries.html' %} +
+
+
+{% endblock %} + diff --git a/pastebin/urls.py b/pastebin/urls.py index 2ccd88a..44d2610 100644 --- a/pastebin/urls.py +++ b/pastebin/urls.py @@ -1,8 +1,11 @@ from django.conf.urls import patterns, include, url -from views import GeometryView, GeometryCreate, GeometryDelete +from views import GeometryView, GeometryListView, GeometryCreate, GeometryDelete urlpatterns = patterns('', url(r'^new/$', GeometryCreate.as_view(), name='geometry_create'), - url(r'^g/delete/(?P\d+)/$', GeometryDelete.as_view(), name='geometry_delete'), - url(r'^g/(?P\d+)/$', GeometryView.as_view(), name='geometry_details')) \ No newline at end of file + url(r'^list/$', GeometryListView.as_view(), name='geometry_list'), + url(r'^list/page/(?P[0-9]+)/$', GeometryListView.as_view(), name='geometry_list'), + url(r'^delete/(?P\d+)/$', GeometryDelete.as_view(), name='geometry_delete'), + url(r'^(?P\d+)/$', GeometryView.as_view(), name='geometry_details')) + \ No newline at end of file diff --git a/pastebin/views.py b/pastebin/views.py index 1d1a772..b6547de 100644 --- a/pastebin/views.py +++ b/pastebin/views.py @@ -4,7 +4,7 @@ from django.core.urlresolvers import reverse from django.views.generic.base import ContextMixin from django.core.exceptions import PermissionDenied from django.views.generic.base import TemplateView - +from django.views.generic.list import ListView from forms import GeometryForm, AnonymousGeometryForm from models import Geometry @@ -16,6 +16,14 @@ class LastesGeometriesMixin(ContextMixin): context['latest_geometries'] = Geometry.get_latest() return context +class GeometryListView(ListView, LastesGeometriesMixin): + model = Geometry + paginate_by = 50 + paginate_orphans = 25 + page_kwarg = 'page' + context_object_name = 'geometries' + template_name = 'pastebin/geometry_list.html' + class GeometryView(DetailView): model = Geometry diff --git a/static_common/css/layout.css b/static_common/css/layout.css index 7c9b606..d73b182 100644 --- a/static_common/css/layout.css +++ b/static_common/css/layout.css @@ -60,27 +60,10 @@ body { color: #4C5B89; } .textcontainer a:hover { color: #7E98E5; } - .textcontainer .button-green { - color: white; - background-color: #1CB841; } - .textcontainer .button-green:visited { - color: white; } - .textcontainer .button-green:hover { - color: white; } - .textcontainer .button-red { - color: white; - background-color: #ca3c3c; } - .textcontainer .button-red:visited { - color: white; } - .textcontainer .button-red:hover { - color: white; } - .textcontainer .button-lightblue { - color: white; - background-color: #42B8DD; } - .textcontainer .button-lightblue:visited { - color: white; } - .textcontainer .button-lightblue:hover { - color: white; } + .textcontainer table { + background-color: #ffffff; } + .textcontainer table .odd-row { + background-color: #e4eef2; } .textcontainer .uploads-list { list-style: none; } .textcontainer .pure-form label { @@ -94,3 +77,27 @@ body { .textcontainer .resetlink { font-size: 75%; text-decoration: none; } + +#fileinfos .button-green, .textcontainer .button-green { + color: white; + background-color: #1CB841; } + #fileinfos .button-green:visited, .textcontainer .button-green:visited { + color: white; } + #fileinfos .button-green:hover, .textcontainer .button-green:hover { + color: white; } + +#fileinfos .button-red, .textcontainer .button-red { + color: white; + background-color: #ca3c3c; } + #fileinfos .button-red:visited, .textcontainer .button-red:visited { + color: white; } + #fileinfos .button-red:hover, .textcontainer .button-red:hover { + color: white; } + +#fileinfos .button-lightblue, .textcontainer .button-lightblue { + color: white; + background-color: #42B8DD; } + #fileinfos .button-lightblue:visited, .textcontainer .button-lightblue:visited { + color: white; } + #fileinfos .button-lightblue:hover, .textcontainer .button-lightblue:hover { + color: white; } diff --git a/static_common/css/layout.scss b/static_common/css/layout.scss index 1b42bfe..1c65922 100644 --- a/static_common/css/layout.scss +++ b/static_common/css/layout.scss @@ -100,24 +100,14 @@ body{ } } + table { + background-color: #ffffff; - .button-green { - @include fixlinkcolor(#ffffff); - background-color: #1CB841; - + .odd-row { + background-color: #e4eef2; + } } - .button-red { - @include fixlinkcolor(#ffffff); - background-color: #ca3c3c; - } - - .button-lightblue { - @include fixlinkcolor(#ffffff); - background-color: #42B8DD; - } - - .uploads-list { list-style: none; } @@ -144,4 +134,19 @@ body{ } } +#fileinfos .button-green, .textcontainer .button-green { + @include fixlinkcolor(#ffffff); + background-color: #1CB841; +} + +#fileinfos .button-red, .textcontainer .button-red { + @include fixlinkcolor(#ffffff); + background-color: #ca3c3c; +} + +#fileinfos .button-lightblue, .textcontainer .button-lightblue { + @include fixlinkcolor(#ffffff); + background-color: #42B8DD; +} + diff --git a/templates/base.html b/templates/base.html index 6ae8b80..989a546 100644 --- a/templates/base.html +++ b/templates/base.html @@ -22,6 +22,7 @@
  • Home
  • New Paste
  • +
  • Public Pastes
  • {% if user.is_authenticated %}
  • Account
  • Logout
  • diff --git a/templates/home.html b/templates/home.html index e62abf2..5534d7e 100644 --- a/templates/home.html +++ b/templates/home.html @@ -35,8 +35,10 @@
  • Models uploaded by registred user stay online indefinitely
Private only means that past3d will not show the link to anyone else. - Whereas a public paste can be shown at various places on this site, - e.g. the Latest Uploads sidebar. + Whereas a public paste can be shown the Latest Uploads sidebar and + the list of all public pastes. + So if you want your stuff to stay private don't post the link on twitter + or your favorite 3 printing forum, because once the googlebot has it it's public.

Also note that as an unregistered user your models will only stay online for a limited time span (up to one month maximum).