summaryrefslogtreecommitdiff
path: root/app/unused_apps/sketches
diff options
context:
space:
mode:
Diffstat (limited to 'app/unused_apps/sketches')
-rw-r--r--app/unused_apps/sketches/__init__.py0
-rw-r--r--app/unused_apps/sketches/admin.py42
-rw-r--r--app/unused_apps/sketches/build.py36
-rw-r--r--app/unused_apps/sketches/migrations/0001_initial.py32
-rw-r--r--app/unused_apps/sketches/migrations/0002_auto_20180208_0743.py17
-rw-r--r--app/unused_apps/sketches/migrations/0003_auto_20190303_1057.py24
-rw-r--r--app/unused_apps/sketches/migrations/__init__.py0
-rw-r--r--app/unused_apps/sketches/models.py89
-rw-r--r--app/unused_apps/sketches/urls.py39
-rw-r--r--app/unused_apps/sketches/views.py40
10 files changed, 0 insertions, 319 deletions
diff --git a/app/unused_apps/sketches/__init__.py b/app/unused_apps/sketches/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/app/unused_apps/sketches/__init__.py
+++ /dev/null
diff --git a/app/unused_apps/sketches/admin.py b/app/unused_apps/sketches/admin.py
deleted file mode 100644
index 0c59867..0000000
--- a/app/unused_apps/sketches/admin.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from django.contrib import admin
-from django.contrib.gis.admin import OSMGeoAdmin
-from django.contrib.contenttypes.admin import GenericTabularInline
-
-from .models import Sketch
-from utils.widgets import LGEntryForm, OLAdminBase
-from utils.util import get_latlon
-
-
-@admin.register(Sketch)
-class SketchAdmin(OLAdminBase):
- form = LGEntryForm
- prepopulated_fields = {"slug": ('title',)}
- list_display = ('title', 'slug', 'pub_date', 'location')
- fieldsets = (
- ('Note', {
- 'fields': (
- 'title',
- 'subtitle',
- 'body_markdown',
- 'slug',
- ('pub_date', 'status'),
- 'point'
- ),
- 'classes': (
- 'show',
- 'extrapretty',
- 'wide'
- )
- }
- ),
- )
- lat, lon = get_latlon()
- default_lon = lon
- default_lat = lat
- default_zoom = 10
-
- class Media:
- js = ('image-loader.js', 'next-prev-links.js')
-
-
-
diff --git a/app/unused_apps/sketches/build.py b/app/unused_apps/sketches/build.py
deleted file mode 100644
index e75b6fd..0000000
--- a/app/unused_apps/sketches/build.py
+++ /dev/null
@@ -1,36 +0,0 @@
-import os
-from django.urls import reverse
-from builder.base import BuildNew
-
-
-class BuildSketches(BuildNew):
-
- def build(self):
- self.build_detail_view()
- self.build_list_view(
- base_path=reverse("sketches:list"),
- paginate_by=24
- )
- self.build_year_view("sketches:list_year")
- self.build_month_view("sketches:list_month")
-
- def get_model_queryset(self):
- return self.model.objects.all()
-
- def build_detail_view(self):
- '''
- write out all the expenses for each trip
- '''
- for obj in self.get_model_queryset():
- url = obj.get_absolute_url()
- path, slug = os.path.split(url)
- path = '%s/' % path
- # write html
- response = self.client.get(url)
- print(path, slug)
- self.write_file(path, response.content, filename=slug)
-
-
-def builder():
- j = BuildSketches("sketches", "sketch")
- j.build()
diff --git a/app/unused_apps/sketches/migrations/0001_initial.py b/app/unused_apps/sketches/migrations/0001_initial.py
deleted file mode 100644
index 1e034b4..0000000
--- a/app/unused_apps/sketches/migrations/0001_initial.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Generated by Django 2.0.1 on 2018-02-01 20:56
-
-import django.contrib.gis.db.models.fields
-from django.db import migrations, models
-import django.db.models.deletion
-import django.utils.timezone
-
-
-class Migration(migrations.Migration):
-
- initial = True
-
- dependencies = [
- ('locations', '0002_checkin'),
- ]
-
- operations = [
- migrations.CreateModel(
- name='Sketch',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('title', models.CharField(blank=True, max_length=250, null=True)),
- ('slug', models.SlugField(blank=True, unique_for_date='pub_date')),
- ('pub_date', models.DateTimeField(default=django.utils.timezone.now)),
- ('body_html', models.TextField(blank=True)),
- ('body_markdown', models.TextField(verbose_name='Note')),
- ('point', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)),
- ('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Published')], default=1)),
- ('location', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Location')),
- ],
- ),
- ]
diff --git a/app/unused_apps/sketches/migrations/0002_auto_20180208_0743.py b/app/unused_apps/sketches/migrations/0002_auto_20180208_0743.py
deleted file mode 100644
index 664fcbc..0000000
--- a/app/unused_apps/sketches/migrations/0002_auto_20180208_0743.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Generated by Django 2.0.1 on 2018-02-08 07:43
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('sketches', '0001_initial'),
- ]
-
- operations = [
- migrations.AlterModelOptions(
- name='sketch',
- options={'get_latest_by': 'pub_date', 'ordering': ('-pub_date',), 'verbose_name_plural': 'sketches'},
- ),
- ]
diff --git a/app/unused_apps/sketches/migrations/0003_auto_20190303_1057.py b/app/unused_apps/sketches/migrations/0003_auto_20190303_1057.py
deleted file mode 100644
index 87cfbf1..0000000
--- a/app/unused_apps/sketches/migrations/0003_auto_20190303_1057.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Generated by Django 2.1.7 on 2019-03-03 10:57
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('sketches', '0002_auto_20180208_0743'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='sketch',
- name='subtitle',
- field=models.CharField(blank=True, max_length=250),
- ),
- migrations.AlterField(
- model_name='sketch',
- name='title',
- field=models.CharField(blank=True, default='', max_length=250),
- preserve_default=False,
- ),
- ]
diff --git a/app/unused_apps/sketches/migrations/__init__.py b/app/unused_apps/sketches/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/app/unused_apps/sketches/migrations/__init__.py
+++ /dev/null
diff --git a/app/unused_apps/sketches/models.py b/app/unused_apps/sketches/models.py
deleted file mode 100644
index f6df269..0000000
--- a/app/unused_apps/sketches/models.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import re
-from django.contrib.gis.db import models
-from django.utils import timezone
-from django.conf import settings
-from django import forms
-from locations.models import Location
-from django.urls import reverse
-
-from utils.util import render_images, parse_image, markdown_to_html
-from locations.models import CheckIn
-
-def render_images(s):
- s = re.sub('<img(.*)/>', parse_image, s)
- return s
-
-class Sketch(models.Model):
- title = models.CharField(max_length=250, blank=True)
- subtitle = models.CharField(max_length=250,blank=True)
- slug = models.SlugField(unique_for_date='pub_date', blank=True)
- pub_date = models.DateTimeField(default=timezone.now)
- body_html = models.TextField(blank=True)
- body_markdown = models.TextField('Note')
- point = models.PointField(blank=True, null=True)
- location = models.ForeignKey(Location, on_delete=models.CASCADE, blank=True, null=True)
- PUB_STATUS = (
- (0, 'Draft'),
- (1, 'Published'),
- )
- status = models.IntegerField(choices=PUB_STATUS, default=1)
-
- class Meta:
- ordering = ('-pub_date',)
- get_latest_by = 'pub_date'
- verbose_name_plural = 'sketches'
-
- def __str__(self):
- return self.title
-
- def get_absolute_url(self):
- return reverse("sketches:detail", kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug})
-
- @property
- def region(self):
- return self.location.state.country.lux_region
-
- @property
- def longitude(self):
- '''Get the site's longitude.'''
- return round(self.point.x, 2)
-
- @property
- def latitude(self):
- '''Get the site's latitude.'''
- return round(self.point.y, 2)
-
- @property
- def get_previous_published(self):
- return self.get_previous_by_pub_date()
-
- @property
- def get_next_published(self):
- return self.get_next_by_pub_date()
-
- @property
- def get_previous_admin_url(self):
- n = self.get_previous_by_pub_date()
- return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] )
-
- @property
- def get_next_admin_url(self):
- model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name)
- try:
- return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] )
- except model.DoesNotExist:
- return ''
-
- def save(self, *args, **kwargs):
- md = render_images(self.body_markdown)
- self.body_html = markdown_to_html(md)
- if not self.point:
- self.point = CheckIn.objects.latest().point
- try:
- self.location = Location.objects.filter(geometry__contains=self.point).get()
- except Location.DoesNotExist:
- raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL))
- if not self.id:
- self.pub_date= timezone.now()
- self.date_last_updated = timezone.now()
- super(Sketch, self).save()
diff --git a/app/unused_apps/sketches/urls.py b/app/unused_apps/sketches/urls.py
deleted file mode 100644
index 465a0d2..0000000
--- a/app/unused_apps/sketches/urls.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from django.urls import path, re_path
-
-from . import views
-
-app_name = "sketches"
-
-urlpatterns = [
- re_path(
- r'(?P<year>[0-9]{4})/$',
- views.SketchYearArchiveView.as_view(),
- name="list_year"
- ),
- path(
- r'',
- views.SketchListView.as_view(),
- {'page': 1},
- name="list"
- ),
- path(
- r'<int:page>/',
- views.SketchListView.as_view(),
- name="list"
- ),
- path(
- r'<int:year>/<int:month>/<str:slug>.txt',
- views.SketchDetailViewTXT.as_view(),
- name="detail-txt"
- ),
- path(
- r'<int:year>/<int:month>/<str:slug>',
- views.SketchDetailView.as_view(),
- name="detail"
- ),
- path(
- r'<int:year>/<int:month>/',
- views.SketchMonthArchiveView.as_view(month_format='%m'),
- name="list_month"
- ),
-]
diff --git a/app/unused_apps/sketches/views.py b/app/unused_apps/sketches/views.py
deleted file mode 100644
index b696932..0000000
--- a/app/unused_apps/sketches/views.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from django.views.generic.dates import YearArchiveView, MonthArchiveView
-from django.views.generic.detail import DetailView
-
-from utils.views import PaginatedListView
-
-from .models import Sketch
-
-
-class SketchListView(PaginatedListView):
- """
- Return a list of Notes in reverse chronological order
- """
- queryset = Sketch.objects.all().order_by('-pub_date')
- template_name = "archives/sketches.html"
-
-
-class SketchDetailView(DetailView):
- model = Sketch
- template_name = "details/note.html"
- slug_field = "slug"
-
-
-class SketchDetailViewTXT(SketchDetailView):
- template_name = "details/entry.txt"
-
-
-class SketchYearArchiveView(YearArchiveView):
- queryset = Sketch.objects.all()
- date_field = "pub_date"
- make_object_list = True
- allow_future = True
- template_name = "archives/notes_date.html"
-
-
-class SketchMonthArchiveView(MonthArchiveView):
- queryset = Sketch.objects.all()
- date_field = "pub_date"
- allow_future = True
- template_name = "archives/notes_date.html"
-