summaryrefslogtreecommitdiff
path: root/app/expenses
diff options
context:
space:
mode:
Diffstat (limited to 'app/expenses')
-rw-r--r--app/expenses/__init__.py0
-rw-r--r--app/expenses/admin.py25
-rw-r--r--app/expenses/build.py34
-rw-r--r--app/expenses/migrations/0001_initial.py48
-rw-r--r--app/expenses/migrations/0002_luxexpense.py26
-rw-r--r--app/expenses/migrations/0003_auto_20170429_0748.py40
-rw-r--r--app/expenses/migrations/__init__.py0
-rw-r--r--app/expenses/models.py62
-rw-r--r--app/expenses/urls.py22
-rw-r--r--app/expenses/views.py38
10 files changed, 0 insertions, 295 deletions
diff --git a/app/expenses/__init__.py b/app/expenses/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/app/expenses/__init__.py
+++ /dev/null
diff --git a/app/expenses/admin.py b/app/expenses/admin.py
deleted file mode 100644
index a754883..0000000
--- a/app/expenses/admin.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from django.contrib import admin
-
-from .models import LuxExpense, Trip, Expense, Month
-
-
-@admin.register(Trip)
-class TripAdmin(admin.ModelAdmin):
- list_display = ('name', 'start')
-
-
-@admin.register(Expense)
-class ExpenseAdmin(admin.ModelAdmin):
- list_display = ('name', 'category', 'amount', 'date_month')
- list_filter = ('date', 'category')
-
-
-@admin.register(LuxExpense)
-class LuxExpenseAdmin(admin.ModelAdmin):
- list_display = ('category', 'amount', 'month')
- list_filter = ('month', 'category')
-
-
-@admin.register(Month)
-class MonthAdmin(admin.ModelAdmin):
- pass
diff --git a/app/expenses/build.py b/app/expenses/build.py
deleted file mode 100644
index 7241a70..0000000
--- a/app/expenses/build.py
+++ /dev/null
@@ -1,34 +0,0 @@
-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/expenses/migrations/0001_initial.py b/app/expenses/migrations/0001_initial.py
deleted file mode 100644
index 5ff70cd..0000000
--- a/app/expenses/migrations/0001_initial.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.9 on 2017-04-28 22:47
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-import django.db.models.deletion
-import django.utils.timezone
-
-
-class Migration(migrations.Migration):
-
- initial = True
-
- dependencies = [
- ]
-
- operations = [
- migrations.CreateModel(
- name='Expense',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=200)),
- ('amount', models.DecimalField(decimal_places=2, max_digits=8)),
- ('date', models.DateTimeField(default=django.utils.timezone.now)),
- ('notes', models.TextField(blank=True, null=True)),
- ('category', models.CharField(choices=[('1', 'Groceries'), ('2', 'Restaurants'), ('3', 'Camping'), ('4', 'Petrol'), ('5', 'Bus'), ('6', 'Misc')], default=1, max_length=2)),
- ],
- options={
- 'ordering': ('-date',),
- },
- ),
- migrations.CreateModel(
- name='Trip',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=200)),
- ('slug', models.SlugField()),
- ('start', models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True)),
- ('end', models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True)),
- ('dek', models.TextField(blank=True, null=True)),
- ],
- ),
- migrations.AddField(
- model_name='expense',
- name='trip',
- field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='expenses.Trip'),
- ),
- ]
diff --git a/app/expenses/migrations/0002_luxexpense.py b/app/expenses/migrations/0002_luxexpense.py
deleted file mode 100644
index 9edfdb4..0000000
--- a/app/expenses/migrations/0002_luxexpense.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.9 on 2017-04-28 22:48
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-import django.utils.timezone
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('expenses', '0001_initial'),
- ]
-
- operations = [
- migrations.CreateModel(
- name='LuxExpense',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('category', models.CharField(choices=[('1', 'Groceries'), ('2', 'Restaurants'), ('3', 'Camping'), ('4', 'Petrol'), ('5', 'Bus'), ('6', 'Misc')], default=1, max_length=2)),
- ('amount', models.DecimalField(decimal_places=2, max_digits=8)),
- ('date', models.DateTimeField(default=django.utils.timezone.now)),
- ('notes', models.TextField(blank=True, null=True)),
- ],
- ),
- ]
diff --git a/app/expenses/migrations/0003_auto_20170429_0748.py b/app/expenses/migrations/0003_auto_20170429_0748.py
deleted file mode 100644
index 69f14ec..0000000
--- a/app/expenses/migrations/0003_auto_20170429_0748.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.9 on 2017-04-29 07:48
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-import django.db.models.deletion
-import django.utils.timezone
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('expenses', '0002_luxexpense'),
- ]
-
- operations = [
- migrations.CreateModel(
- name='Month',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=200)),
- ('year', models.IntegerField()),
- ('date', models.DateTimeField(default=django.utils.timezone.now)),
- ('notes', models.TextField(blank=True, null=True)),
- ],
- ),
- migrations.RemoveField(
- model_name='luxexpense',
- name='date',
- ),
- migrations.RemoveField(
- model_name='luxexpense',
- name='notes',
- ),
- migrations.AddField(
- model_name='luxexpense',
- name='month',
- field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='expenses.Month'),
- ),
- ]
diff --git a/app/expenses/migrations/__init__.py b/app/expenses/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/app/expenses/migrations/__init__.py
+++ /dev/null
diff --git a/app/expenses/models.py b/app/expenses/models.py
deleted file mode 100644
index fbcdd7a..0000000
--- a/app/expenses/models.py
+++ /dev/null
@@ -1,62 +0,0 @@
-from django.db import models
-from django.urls import reverse
-from django.utils import timezone
-
-CATS = (
- ('1', "Groceries"),
- ('2', "Restaurants"),
- ('3', "Camping"),
- ('4', "Petrol"),
- ('5', "Bus"),
- ('6', "Misc"),
-)
-
-
-class Trip(models.Model):
- name = models.CharField(max_length=200)
- slug = models.SlugField()
- start = models.DateTimeField(default=timezone.now, blank=True, null=True)
- end = models.DateTimeField(default=timezone.now, blank=True, null=True)
- dek = models.TextField(null=True, blank=True)
-
- def __str__(self):
- return self.name
-
- def get_absolute_url(self):
- return reverse("expenses:list_expense", kwargs={"slug": self.slug})
-
-class Month(models.Model):
- name = models.CharField(max_length=200)
- year = models.IntegerField()
- date = models.DateTimeField(default=timezone.now)
- notes = models.TextField(null=True, blank=True)
-
- def __str__(self):
- return "%s %s" %(self.name, self.year)
-
-class LuxExpense(models.Model):
- category = models.CharField(max_length=2, choices=CATS, default=1)
- amount = models.DecimalField(max_digits=8, decimal_places=2)
- month = models.ForeignKey(Month, on_delete=models.CASCADE, null=True)
-
- def __str__(self):
- return '%s-%s' %(self.month, self.get_category_display())
-
-
-
-class Expense(models.Model):
- name = models.CharField(max_length=200)
- amount = models.DecimalField(max_digits=8, decimal_places=2)
- date = models.DateTimeField(default=timezone.now)
- notes = models.TextField(null=True, blank=True)
- category = models.CharField(max_length=2, choices=CATS, default=1)
- trip = models.ForeignKey(Trip, on_delete=models.CASCADE, null=True)
-
- class Meta:
- ordering = ('-date',)
-
- def __str__(self):
- return self.name
-
- def date_month(self):
- return self.date.strftime("%b %Y")
diff --git a/app/expenses/urls.py b/app/expenses/urls.py
deleted file mode 100644
index 6ad732e..0000000
--- a/app/expenses/urls.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from django.conf.urls import url
-from . import views
-
-app_name = "expenses"
-
-urlpatterns = [
- #url(
- # r'(?P<slug>[-\w]+)$',
- # views.ExpenseListView.as_view(),
- # name='list_expense'
- #),
- url(
- r'(?P<slug>[-\w]+)$',
- views.LuxExpenseListView.as_view(),
- name='list_expense'
- ),
- url(
- r'^$',
- views.TripListView.as_view(),
- name='list_trip'
- )
-]
diff --git a/app/expenses/views.py b/app/expenses/views.py
deleted file mode 100644
index 98a4c70..0000000
--- a/app/expenses/views.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from django.views.generic import ListView
-
-from .models import LuxExpense, Expense, Trip, CATS
-
-class ExpenseListView(ListView):
- model = Expense
- context_object_name = 'object_list'
- template_name = 'details/expenses.html'
-
- def get_queryset(self):
- return Expense.objects.filter(
- trip__slug=self.kwargs['slug']
- )
-
- def get_context_data(self, **kwargs):
- # Call the base implementation first to get a context
- context = super(ExpenseListView, self).get_context_data(**kwargs)
- context['categories'] = CATS
- return context
-
-class LuxExpenseListView(ListView):
- model = LuxExpense
- context_object_name = 'object_list'
- template_name = 'details/expenses.html'
-
- def get_context_data(self, **kwargs):
- # Call the base implementation first to get a context
- context = super(LuxExpenseListView, self).get_context_data(**kwargs)
- context['categories'] = CATS
- return context
-
-class TripListView(ListView):
- model = Trip
- context_object_name = 'object_list'
- template_name = 'archives/expenses.html'
-
- def get_queryset(self):
- return Trip.objects.all()