summaryrefslogtreecommitdiff
path: root/app/resume
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2015-11-15 08:27:16 -0500
committerluxagraf <sng@luxagraf.net>2015-11-15 08:27:16 -0500
commit10402b86a75c83a02945b5528010dcefab41fc37 (patch)
tree7a6f7f22f44d15757b805b45d0649b867c3c2ccb /app/resume
parent623974bd1b0a130be71f5db7b41c38c43b0bf613 (diff)
added resume and income apps
Diffstat (limited to 'app/resume')
-rw-r--r--app/resume/admin.py14
-rw-r--r--app/resume/build.py34
-rw-r--r--app/resume/models.py40
-rw-r--r--app/resume/urls.py32
-rw-r--r--app/resume/views.py31
5 files changed, 151 insertions, 0 deletions
diff --git a/app/resume/admin.py b/app/resume/admin.py
new file mode 100644
index 0000000..0f8b71a
--- /dev/null
+++ b/app/resume/admin.py
@@ -0,0 +1,14 @@
+from django.contrib import admin
+
+from .models import Publisher, PubItem
+
+
+class PublisherAdmin(admin.ModelAdmin):
+ pass
+
+
+class PubItemAdmin(admin.ModelAdmin):
+ pass
+
+admin.site.register(Publisher, PublisherAdmin)
+admin.site.register(PubItem, PubItemAdmin)
diff --git a/app/resume/build.py b/app/resume/build.py
new file mode 100644
index 0000000..7241a70
--- /dev/null
+++ b/app/resume/build.py
@@ -0,0 +1,34 @@
+import os
+from django.core.urlresolvers import reverse
+from builder.base import BuildNew
+
+
+class BuildExpenses(BuildNew):
+
+ def build(self):
+ self.build_detail_view()
+ self.build_list_view(
+ base_path=reverse("expenses:list_trip"),
+ paginate_by=24
+ )
+
+ 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 = BuildExpenses("expenses", "trip")
+ j.build()
diff --git a/app/resume/models.py b/app/resume/models.py
new file mode 100644
index 0000000..4df639e
--- /dev/null
+++ b/app/resume/models.py
@@ -0,0 +1,40 @@
+from django.db import models
+from django.core.urlresolvers import reverse
+
+# http://freewisdom.org/projects/python-markdown/
+import markdown
+
+
+class Publisher(models.Model):
+ name = models.CharField(max_length=200)
+ slug = models.SlugField(max_length=50)
+ body_markdown = models.TextField(null=True, blank=True)
+ body_html = models.TextField(null=True, blank=True)
+ url = models.CharField(max_length=200, blank=True, null=True)
+
+ def __str__(self):
+ return self.name
+
+
+class PubItem(models.Model):
+ title = models.CharField(max_length=200)
+ slug = models.CharField(max_length=50)
+ body_markdown = models.TextField(null=True, blank=True)
+ body_html = models.TextField(null=True, blank=True)
+ url = models.CharField(max_length=200, blank=True, null=True)
+ pub_date = models.CharField(max_length=40, blank=True, null=True)
+ publisher = models.ForeignKey(Publisher)
+
+ class Meta:
+ ordering = ('-pub_date',)
+
+ def __str__(self):
+ return self.title
+
+ def get_absolute_url(self):
+ return reverse("resume:detail", kwargs={"publisher": self.publisher.slug, "slug": self.slug})
+
+ def save(self, *args, **kwargs):
+ if self.body_markdown:
+ self.body_html = markdown.markdown(self.body_markdown, extensions=['extra'], safe_mode=False)
+ super(PubItem, self).save()
diff --git a/app/resume/urls.py b/app/resume/urls.py
new file mode 100644
index 0000000..15b2371
--- /dev/null
+++ b/app/resume/urls.py
@@ -0,0 +1,32 @@
+from django.conf.urls import url
+from django.views.generic.base import RedirectView
+
+from . import views
+
+urlpatterns = [
+ url(
+ regex=r'pubs/(?P<page>\d+)/$',
+ view=views.PublisherListView.as_view(),
+ name='list',
+ ),
+ url(
+ regex=r'pubs/(?P<publisher>[-\w]+)/(?P<slug>[-\w]+)$',
+ view=views.PubItemDetailView.as_view(),
+ name='detail',
+ ),
+ url(
+ regex=r'pubs/$',
+ view=RedirectView.as_view(url="/resume/pubs/1/", permanent=False),
+ name="live-redirect"
+ ),
+ url(
+ regex=r'^(?P<slug>[-\w]+)$',
+ view=views.PageView.as_view(),
+ name="intro"
+ ),
+ url(
+ regex=r'^$',
+ view=views.BaseView.as_view(),
+ name="cv"
+ ),
+]
diff --git a/app/resume/views.py b/app/resume/views.py
new file mode 100644
index 0000000..bdfd01b
--- /dev/null
+++ b/app/resume/views.py
@@ -0,0 +1,31 @@
+from django.views.generic.detail import DetailView
+from django.views.generic.base import TemplateView
+from utils.views import PaginatedListView
+
+from .models import PubItem
+from pages.models import Page
+
+
+class PublisherListView(PaginatedListView):
+ template_name = 'archives/resume-pubs.html'
+
+ def get_queryset(self):
+ return PubItem.objects.all()
+
+
+class PubItemDetailView(DetailView):
+ model = PubItem
+ template_name = "details/resume.html"
+ slug_field = "slug"
+
+
+class PageView(DetailView):
+ model = Page
+ slug_field = "slug"
+
+ def get_template_names(self):
+ return ["details/%s.html" % self.object.slug, 'details/page.html']
+
+
+class BaseView(TemplateView):
+ template_name = "archives/resume.html"