summaryrefslogtreecommitdiff
path: root/bak/unused_apps/expenses
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-07-28 13:39:02 -0500
committerluxagraf <sng@luxagraf.net>2023-07-28 13:39:02 -0500
commit9a620cf42bf1fe6977e378bd834b41ff4a593dde (patch)
treecf41a0582681cecaf88a30bfe409f9c2be57972a /bak/unused_apps/expenses
parent6e5897117124cd60ae81efb1574c6347f48e60e5 (diff)
main: removed some apps I wasn't using and added bak to git to preserve
a copy of old apps
Diffstat (limited to 'bak/unused_apps/expenses')
-rw-r--r--bak/unused_apps/expenses/__init__.py0
-rw-r--r--bak/unused_apps/expenses/admin.py25
-rw-r--r--bak/unused_apps/expenses/build.py34
-rw-r--r--bak/unused_apps/expenses/migrations/0001_initial.py48
-rw-r--r--bak/unused_apps/expenses/migrations/0002_luxexpense.py26
-rw-r--r--bak/unused_apps/expenses/migrations/0003_auto_20170429_0748.py40
-rw-r--r--bak/unused_apps/expenses/migrations/__init__.py0
-rw-r--r--bak/unused_apps/expenses/models.py62
-rw-r--r--bak/unused_apps/expenses/urls.py22
-rw-r--r--bak/unused_apps/expenses/views.py38
10 files changed, 295 insertions, 0 deletions
diff --git a/bak/unused_apps/expenses/__init__.py b/bak/unused_apps/expenses/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/bak/unused_apps/expenses/__init__.py
diff --git a/bak/unused_apps/expenses/admin.py b/bak/unused_apps/expenses/admin.py
new file mode 100644
index 0000000..a754883
--- /dev/null
+++ b/bak/unused_apps/expenses/admin.py
@@ -0,0 +1,25 @@
+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/bak/unused_apps/expenses/build.py b/bak/unused_apps/expenses/build.py
new file mode 100644
index 0000000..7241a70
--- /dev/null
+++ b/bak/unused_apps/expenses/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/bak/unused_apps/expenses/migrations/0001_initial.py b/bak/unused_apps/expenses/migrations/0001_initial.py
new file mode 100644
index 0000000..5ff70cd
--- /dev/null
+++ b/bak/unused_apps/expenses/migrations/0001_initial.py
@@ -0,0 +1,48 @@
+# -*- 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/bak/unused_apps/expenses/migrations/0002_luxexpense.py b/bak/unused_apps/expenses/migrations/0002_luxexpense.py
new file mode 100644
index 0000000..9edfdb4
--- /dev/null
+++ b/bak/unused_apps/expenses/migrations/0002_luxexpense.py
@@ -0,0 +1,26 @@
+# -*- 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/bak/unused_apps/expenses/migrations/0003_auto_20170429_0748.py b/bak/unused_apps/expenses/migrations/0003_auto_20170429_0748.py
new file mode 100644
index 0000000..69f14ec
--- /dev/null
+++ b/bak/unused_apps/expenses/migrations/0003_auto_20170429_0748.py
@@ -0,0 +1,40 @@
+# -*- 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/bak/unused_apps/expenses/migrations/__init__.py b/bak/unused_apps/expenses/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/bak/unused_apps/expenses/migrations/__init__.py
diff --git a/bak/unused_apps/expenses/models.py b/bak/unused_apps/expenses/models.py
new file mode 100644
index 0000000..fbcdd7a
--- /dev/null
+++ b/bak/unused_apps/expenses/models.py
@@ -0,0 +1,62 @@
+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/bak/unused_apps/expenses/urls.py b/bak/unused_apps/expenses/urls.py
new file mode 100644
index 0000000..6ad732e
--- /dev/null
+++ b/bak/unused_apps/expenses/urls.py
@@ -0,0 +1,22 @@
+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/bak/unused_apps/expenses/views.py b/bak/unused_apps/expenses/views.py
new file mode 100644
index 0000000..98a4c70
--- /dev/null
+++ b/bak/unused_apps/expenses/views.py
@@ -0,0 +1,38 @@
+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()