From efb623af0bcb47d510501c282e1326b11343a29c Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sat, 22 Sep 2012 22:27:04 -0400 Subject: site reorg --- apps/guide/__init__.py | 0 apps/guide/admin.py | 63 ----------------------- apps/guide/models.py | 135 ------------------------------------------------- apps/guide/urls.py | 11 ---- apps/guide/views.py | 34 ------------- 5 files changed, 243 deletions(-) delete mode 100644 apps/guide/__init__.py delete mode 100644 apps/guide/admin.py delete mode 100644 apps/guide/models.py delete mode 100644 apps/guide/urls.py delete mode 100644 apps/guide/views.py (limited to 'apps/guide') diff --git a/apps/guide/__init__.py b/apps/guide/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apps/guide/admin.py b/apps/guide/admin.py deleted file mode 100644 index 55f713f..0000000 --- a/apps/guide/admin.py +++ /dev/null @@ -1,63 +0,0 @@ -from django.contrib import admin -from django import forms -from guide.models import Guide -from django.contrib.gis.admin import OSMGeoAdmin -from django.contrib.gis.maps.google import GoogleMap -from django.conf import settings - - - -GMAP = GoogleMap(key=settings.GOOGLE_MAPS_API_KEY) - -class GuideAdmin(OSMGeoAdmin): - list_display = ('title', 'pub_date','template_name', 'status','region','location','photo_gallery') - search_fields = ['title', 'body_markdown'] - prepopulated_fields = {"slug" : ('title',)} - list_filter = ('pub_date', 'status','region','location') - fieldsets = ( - ('Note', {'fields': ('title','body_markdown', ('location','region'), 'pub_date', 'status', 'slug','photo_gallery'), 'classes': ('show','extrapretty','wide')}), - ('Extra', {'fields': ('dek', 'meta_description','template_name', ('image', 'thumbnail')), 'classes': ('collapse', 'wide')}), - ) - - class Media: - js = ['/media/admin/custom/model.js'] - extra_js = [GMAP.api_url + GMAP.key] - map_template = 'gis/admin/google.html' - #map_template = 'gis/admin/google.html' - # Default GeoDjango OpenLayers map options - # Uncomment and modify as desired - # To learn more about this jargon visit: - # www.openlayers.org - - default_lon = -9314310 - default_lat = 3991847 - default_zoom = 6 - #display_wkt = False - #display_srid = False - #extra_js = [] - #num_zoom = 18 - #max_zoom = False - #min_zoom = False - #units = False - #max_resolution = False - #max_extent = False - #modifiable = True - #mouse_position = True - #scale_text = True - #layerswitcher = True - scrollable = False - #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX - map_width = 700 - map_height = 325 - #map_srid = 4326 - #map_template = 'gis/admin/openlayers.html' - #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js' - #wms_url = 'http://labs.metacarta.com/wms/vmap0' - #wms_layer = 'basic' - #wms_name = 'OpenLayers WMS' - #debug = False - #widget = OpenLayersWidget - - - -admin.site.register(Guide, GuideAdmin) diff --git a/apps/guide/models.py b/apps/guide/models.py deleted file mode 100644 index 793b9f4..0000000 --- a/apps/guide/models.py +++ /dev/null @@ -1,135 +0,0 @@ -import datetime -from django.contrib.gis.db import models -from django.conf import settings -from django.contrib.syndication.feeds import Feed -from django.contrib.sitemaps import Sitemap -from django.template.defaultfilters import truncatewords_html -from PIL import Image - - -from utils import markdown2 as markdown -from taggit.managers import TaggableManager -from locations.models import Location,Region,Country -from blog.models import Entry -from photos.models import PhotoGallery - -def get_upload_path(self, filename): - return "images/guide-images/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename) - -def get_tn_path(self, filename): - return "images/guide-thumbnail/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename) - -def image_url_replace(str): - str = str.replace('[[base_url]]', settings.IMAGES_URL) - return str - -def markdown_processor(md): - return markdown.markdown(md, ['footnotes'],safe_mode = False) - -PUB_STATUS = ( - (0, 'Draft'), - (1, 'Published'), - ) - -TEMPLATES = ( - (0, 'single'), - (1, 'double'), - (2, 'single-dark'), - (3, 'double-dark'), - ) - -class Guide(models.Model): - title = models.CharField(max_length=200) - slug = models.SlugField(unique_for_date='pub_date') - entry = models.ForeignKey(Entry, null=True, blank=True) - body_html = models.TextField(blank=True) - body_markdown = models.TextField() - dek = models.TextField(null=True,blank=True) - pub_date = models.DateTimeField('Date published') - location = models.ForeignKey(Location, null=True, blank=True) - country = models.ForeignKey(Country, null=True, blank=True) - region = models.ForeignKey(Region, null=True, blank=True) - status = models.IntegerField(choices=PUB_STATUS, default=0) - photo_gallery = models.ForeignKey(PhotoGallery, blank=True, null=True, verbose_name='photo set') - meta_description = models.CharField(max_length=256, null=True, blank=True) - template_name = models.IntegerField(choices=TEMPLATES, default=0) - tags = TaggableManager(blank=True) - image = models.FileField(upload_to=get_upload_path, null=True,blank=True) - image_height = models.CharField(max_length=20, null=True,blank=True) - image_width = models.CharField(max_length=20, null=True,blank=True) - thumbnail = models.FileField(upload_to=get_tn_path, null=True,blank=True) - thumb_height = models.CharField(max_length=20, null=True,blank=True) - thumb_width = models.CharField(max_length=20, null=True,blank=True) - - - @property - def longitude(self): - '''Get the site's longitude.''' - return self.point.x - - @property - def latitude(self): - '''Get the site's latitude.''' - return self.point.y - - class Meta: - ordering = ('-pub_date',) - get_latest_by = 'pub_date' - verbose_name_plural = 'entries' - - def __unicode__(self): - return self.title - - def get_absolute_url(self): - if self.location: - return "/travel-guide/location/%s/%s/" % (self.location.slug, self.slug) - else: - return "/travel-guide/%s/" % (self.slug) - - def get_thumbnail_url(self): - image_dir, img = self.thumbnail.url.split('guide-thumbnail/')[1].split('/') - return '%sguide-thumbnail/%s/%s' %(settings.IMAGES_URL, image_dir, img) - - def get_image_url(self): - image_dir, img = self.image.url.split('guide-images/')[1].split('/') - return '%sguide-images/%s/%s' %(settings.IMAGES_URL, image_dir, img) - - def save(self): - #get image dimensions - if self.image: - img = Image.open(self.image) - self.image_width, self.image_height = img.size - #same for thumb - img = Image.open(self.thumbnail) - self.thumb_width, self.thumb_height = img.size - md = image_url_replace(self.body_markdown) - #run markdown - self.body_html = markdown_processor(md) - self.dek == markdown.markdown(self.dek, safe_mode = False) - super(Guide, self).save() - -class GuideSitemap(Sitemap): - changefreq = "never" - priority = 1.0 - - def items(self): - return Entry.objects.filter(status=1) - - def lastmod(self, obj): - return obj.pub_date - -class GuideFull(Feed): - title = "Luxagraf: Topographical Writings" - link = "/writing/" - description = "Latest postings to luxagraf.net" - description_template = 'feeds/blog_description.html' - - def items(self): - return Entry.objects.filter(status__exact=1).order_by('-pub_date')[:10] - - -#from django.dispatch import dispatcher -#from django.db.models import signals - -#signals.post_save.connect(update_recent, sender=Entry) - diff --git a/apps/guide/urls.py b/apps/guide/urls.py deleted file mode 100644 index 75a24e5..0000000 --- a/apps/guide/urls.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.conf.urls.defaults import * -from django.views.generic.simple import redirect_to - -urlpatterns = patterns('', - (r'location/(?P[-\w]+)/(?P[-\w]+)/$', 'guide.views.guide_detail'), - (r'location/(?P[-\w]+)/$', 'guide.views.guide_list_by_location'), - (r'location/$', 'guide.views.location_list'), - (r'(?P\d+)/$', 'guide.views.guide_list'), - (r'(?P[-\w]+)/$', 'guide.views.guide_detail'), - (r'', redirect_to, {'url': '/travel-guide/1/'}), -) diff --git a/apps/guide/views.py b/apps/guide/views.py deleted file mode 100644 index dc63fc5..0000000 --- a/apps/guide/views.py +++ /dev/null @@ -1,34 +0,0 @@ -from django.shortcuts import render_to_response,get_object_or_404 -from django.template import RequestContext -from django.views.generic.list_detail import object_list -from django.core.exceptions import ObjectDoesNotExist - -from guide.models import Guide -from locations.models import Location - -def guide_list(request,page): - """ - List of all guides - """ - request.page_url = '/guide/%d/' - request.page = int(page) - qs = Guide.objects.filter(status__exact=1).order_by('-pub_date').select_related() - return object_list(request, queryset=qs, template_name='archives/guide.html', extra_context={'page':page}) - -def guide_list_by_location(request,location): - qs = Guide.objects.filter(location__slug__exact=location) - return object_list(request, queryset=qs, template_name='archives/writing.html') - -def location_list(request): - """ - List of all locations with guides - """ - qs = Guide.objects.filter(status__exact=1).order_by('-pub_date').select_related() - return object_list(request, queryset=qs, template_name='archives/guide.html') - -def guide_detail(request, slug, location=None): - obj = get_object_or_404(Guide, slug__exact=slug) - return render_to_response('details/guide.html', {'object': obj,}, context_instance=RequestContext(request)) - - - -- cgit v1.2.3-70-g09d2