diff options
-rw-r--r-- | app/expenses/admin.py | 16 | ||||
-rw-r--r-- | app/expenses/migrations/0001_initial.py | 48 | ||||
-rw-r--r-- | app/expenses/migrations/0002_luxexpense.py | 26 | ||||
-rw-r--r-- | app/expenses/migrations/0003_auto_20170429_0748.py | 40 | ||||
-rw-r--r-- | app/expenses/migrations/__init__.py | 0 | ||||
-rw-r--r-- | app/expenses/models.py | 31 | ||||
-rw-r--r-- | app/expenses/urls.py | 7 | ||||
-rw-r--r-- | app/expenses/views.py | 13 | ||||
-rw-r--r-- | design/sass/_writing_details.scss | 5 | ||||
-rw-r--r-- | design/templates/details/expenses.html | 32 |
10 files changed, 179 insertions, 39 deletions
diff --git a/app/expenses/admin.py b/app/expenses/admin.py index 28c8869..a754883 100644 --- a/app/expenses/admin.py +++ b/app/expenses/admin.py @@ -1,15 +1,25 @@ from django.contrib import admin -from .models import Expense, Trip +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.site.register(Expense, ExpenseAdmin) -admin.site.register(Trip, TripAdmin) + +@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/migrations/0001_initial.py b/app/expenses/migrations/0001_initial.py new file mode 100644 index 0000000..5ff70cd --- /dev/null +++ b/app/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/app/expenses/migrations/0002_luxexpense.py b/app/expenses/migrations/0002_luxexpense.py new file mode 100644 index 0000000..9edfdb4 --- /dev/null +++ b/app/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/app/expenses/migrations/0003_auto_20170429_0748.py b/app/expenses/migrations/0003_auto_20170429_0748.py new file mode 100644 index 0000000..69f14ec --- /dev/null +++ b/app/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/app/expenses/migrations/__init__.py b/app/expenses/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/expenses/migrations/__init__.py diff --git a/app/expenses/models.py b/app/expenses/models.py index bca23bf..ff33844 100644 --- a/app/expenses/models.py +++ b/app/expenses/models.py @@ -3,13 +3,12 @@ from django.core.urlresolvers import reverse from django.utils import timezone CATS = ( - ('1', "Travco"), - ('2', "Groceries"), - ('3', "Lodging"), - ('4', "Camping"), - ('5', "Restaurants"), - ('6', "Petrol"), - ('7', "Misc"), + ('1', "Groceries"), + ('2', "Restaurants"), + ('3', "Camping"), + ('4', "Petrol"), + ('5', "Bus"), + ('6', "Misc"), ) @@ -26,6 +25,24 @@ class Trip(models.Model): 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, null=True) + + def __str__(self): + return '%s-%s' %(self.month, self.get_category_display()) + + class Expense(models.Model): name = models.CharField(max_length=200) diff --git a/app/expenses/urls.py b/app/expenses/urls.py index 6b146c3..6ad732e 100644 --- a/app/expenses/urls.py +++ b/app/expenses/urls.py @@ -4,9 +4,14 @@ 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.ExpenseListView.as_view(), + views.LuxExpenseListView.as_view(), name='list_expense' ), url( diff --git a/app/expenses/views.py b/app/expenses/views.py index 3a8d2cb..98a4c70 100644 --- a/app/expenses/views.py +++ b/app/expenses/views.py @@ -1,7 +1,6 @@ from django.views.generic import ListView -from .models import Expense, Trip, CATS - +from .models import LuxExpense, Expense, Trip, CATS class ExpenseListView(ListView): model = Expense @@ -19,6 +18,16 @@ class ExpenseListView(ListView): 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 diff --git a/design/sass/_writing_details.scss b/design/sass/_writing_details.scss index 0d940d8..9f5ff2a 100644 --- a/design/sass/_writing_details.scss +++ b/design/sass/_writing_details.scss @@ -237,6 +237,8 @@ margin-right: auto; display: block; } img.picwide { + background: none; + max-width: 100%; clear: both; margin: 1em 0; @include breakpoint(gamma) { @@ -405,6 +407,7 @@ figure.picwide img.picwide { .row-2 { a:last-of-type img, figure:last-of-type { float: right; + margin-right: 0; } } .pic66 { @@ -456,7 +459,7 @@ figure.picwide img.picwide { } } img.pic5 { - margin: 0 0 6px 0; + margin: 0 6px 6px 0; } .pic25 { max-width: 50%; diff --git a/design/templates/details/expenses.html b/design/templates/details/expenses.html index c81179e..bf9739e 100644 --- a/design/templates/details/expenses.html +++ b/design/templates/details/expenses.html @@ -33,49 +33,31 @@ </tr> <tr class="row even"> <td>Travco restoration</td> - <td class="cat-value">$300.00 </td> + <td class="cat-value">$3000.00*</td> </tr> <tr class="row odd"> - <td>Inverter</td> - <td class="cat-value"></td> + <td>New wheels and Tires</td> + <td class="cat-value">$3041.00</td> </tr> <tr class="row even"> - <td>Solar setup</td> - <td class="cat-value">$81.74 </td> - </tr> - - <tr class="row odd"> - <td>DMV (taxes, title, plates -- $25 annual for tags)</td> - <td class="cat-value">$141.00</td> - </tr> - - <tr class="row even"> - <td>Insurance (1 year)</td> + <td>DMV and insurance (taxes, title, plates -- $25 annual for tags)</td> <td class="cat-value">$125.00 (annual)</td> </tr> - <tr class="row odd"> - <td>Good Sam Membership</td> - <td class="cat-value">$25.00 (annual)</td> - </tr> - <tr class="row even"> - <td>Something</td> - <td class="cat-value"></td> - </tr> <tr class="total"> <td>Total</td> - <td>$???</td> + <td>$13,291.00</td> </tr> </tbody> <tfoot> <tr> - <td colspan="2"><small>*Some expense</small></td> + <td colspan="2"><small>*This is a rough estimate, I did not itemize everything, so this figure is give or take $300</small></td> </tr> </tfoot> </table> - <p class="end">Here's how much we've spent each month we've spent on the road since we left in June 2016.</p> + <p class="end">Here's how much we've spent each month we've spent on the road since we left in April 2017.</p> <h2>Monthly Expenses</h2> {% regroup object_list by date.month as expenses_by_month %}{% for expenses in expenses_by_month %} |