Permalink
Browse files

Removed the date detail page from the site and redirected the global …

…datepicker to the advanced search results for the day the user is seeking. Fixes #49 and fixes #9.
  • Loading branch information...
1 parent b08f259 commit d6524bca7964b4580483271404640da290aa2478 @palewire palewire committed Jul 13, 2012
Showing with 3 additions and 96 deletions.
  1. +0 −26 archive/managers.py
  2. +0 −19 archive/sitemaps.py
  3. +0 −47 archive/views.py
  4. +3 −1 project/templates/base.html
  5. +0 −3 project/urls.py
View
@@ -11,13 +11,6 @@ def active(self):
class UpdateManager(models.Manager):
- def dates(self):
- """
- Returns all the distinct dates that appear in the model.
- """
- return self.uniqify([timezone.localtime(i.start).date()
- for i in self.all()])
-
def live(self):
from django.db import connection
from archive.models import Site
@@ -48,22 +41,3 @@ def live(self):
if latest_count < sites:
obj.in_progress = True
return obj
-
- def uniqify(self, seq, idfun=None):
- # order preserving
- if idfun is None:
- def idfun(x): return x
- seen = {}
- result = []
- for item in seq:
- marker = idfun(item)
- # in old Python versions:
- # if seen.has_key(marker)
- # but in new ones:
- if marker in seen: continue
- seen[marker] = 1
- result.append(item)
- return result
-
-
-
View
@@ -11,24 +11,6 @@ def get_absolute_url(self):
return self.url
-class DateSitemap(Sitemap):
- changefreq = "daily"
- limit = 1000
-
- def items(self):
- return Update.objects.dates()
-
- def lastmod(self, obj):
- return obj
-
- def location(self, obj):
- return reverse('archive-date-detail', args=[
- obj.year,
- obj.month,
- obj.day,
- ])
-
-
class ScreenshotSitemap(Sitemap):
changefreq = "never"
limit = 1000
@@ -92,7 +74,6 @@ def location(self, obj):
SITEMAPS = {
- 'dates': DateSitemap,
'screenshots': ScreenshotSitemap,
'sites': SiteSitemap,
'static': StaticSitemap,
View
@@ -94,50 +94,6 @@ def get_context_data(self, **kwargs):
return context
-class DateDetail(DetailView):
- """
- All the updates on a particular date.
- """
- template_name = 'date_detail.html'
- queryset = Update.objects.dates()
-
- def get_object(self):
- try:
- date_parts = map(int, [
- self.kwargs['year'],
- self.kwargs['month'],
- self.kwargs['day']
- ])
- date_obj = datetime(*date_parts)
- except:
- raise Http404
- for i in self.queryset:
- if i == date_obj.date():
- return date_obj
- raise Http404
-
- def get_context_data(self, **kwargs):
- tz = timezone.get_current_timezone()
- update_list = Update.objects.filter(
- start__range=map(tz.localize, [
- self.object,
- self.object + timedelta(days=1)
- ])
- )
- if not update_list:
- raise Http404
- screenshot_list = Screenshot.objects.filter(
- update__in=update_list,
- ).select_related("site", "update")
- screenshot_groups = []
- for key, group in groupby(screenshot_list, lambda x: x.update):
- screenshot_groups.append((key, group_objects_by_number(list(group), 8)))
- return {
- 'date': self.object,
- 'screenshot_groups': screenshot_groups,
- }
-
-
class SiteDetail(DetailView):
"""
All about a particular site.
@@ -337,9 +293,6 @@ def get_context_data(self, **kwargs):
]
filters['site__in'] = tagged_list
context['tag'] = tag
- else:
- context['has_error'] = True
- context['error_message'] = 'Sorry. You must submit either a site or a tag with every search.'
# Then the date range
if not start_date and not end_date:
@@ -109,7 +109,9 @@
showOn: 'both',
onSelect: function(dateText, inst) {
var parts = dateText.split("/");
- var url = '/date/' + parts[2] + "/" + parts[0] + "/" + parts[1] + "/";
+ var dateStr = parts[2] + "/" + parts[0] + "/" + parts[1];
+ var url = '/advanced-search/?site=&tag=&timezone=UTC' +
+ '&start_date=' + dateStr + '&end_date=' + dateStr;
window.location.href = url;
}
});
View
@@ -21,9 +21,6 @@
name='archive-tag-detail'),
url(r'^update/(?P<pk>\d+)/$', views.UpdateDetail.as_view(),
name='archive-update-detail'),
- url(r'^date/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
- views.DateDetail.as_view(),
- name='archive-date-detail'),
url(r'^screenshot/(?P<pk>\d+)/$', views.ScreenshotDetail.as_view(),
name='archive-screenshot-detail'),
url(r'^advanced-search/$', views.AdvancedSearch.as_view(),

0 comments on commit d6524bc

Please sign in to comment.