From 477f51aed22802347e5e0bf6ec428bd9366c9f89 Mon Sep 17 00:00:00 2001
From: Andrew Williams
Date: Sun, 29 Apr 2012 16:12:55 +0100
Subject: [PATCH] Various changes and formatting updates, making the app easier
to use.
---
pacmanager/core/forms.py | 6 +++---
pacmanager/core/models.py | 9 ++++-----
.../core/templates/core/corporation_contact.html | 4 +---
pacmanager/core/templates/core/corporation_list.html | 3 +++
pacmanager/core/templates/core/key_form.html | 11 ++++++++---
pacmanager/core/templates/core/key_list.html | 2 ++
pacmanager/core/views.py | 8 ++++++++
.../formtools/templates/formtools/formfield.html | 2 +-
pacmanager/pacmanager/templates/base.html | 6 ++++--
9 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/pacmanager/core/forms.py b/pacmanager/core/forms.py
index 9f9ee05..322baf4 100644
--- a/pacmanager/core/forms.py
+++ b/pacmanager/core/forms.py
@@ -17,6 +17,6 @@ class CorporationContactForm(forms.ModelForm):
class ManualAdjustmentForm(forms.Form):
- corporation = forms.ModelChoiceField(queryset=Corporation.objects.all(), empty_label=None)
- amount = forms.DecimalField(max_digits=20, decimal_places=2)
- comment = forms.CharField(max_length=255)
\ No newline at end of file
+ corporation = forms.ModelChoiceField(queryset=Corporation.objects.all(), empty_label=None, help_text="Corporation you wish to apply the adjustment to")
+ amount = forms.DecimalField(max_digits=20, decimal_places=2, help_text="The amount in ISK you wish to adjust the corporation's account by")
+ comment = forms.CharField(max_length=255, help_text="Free-form comment to describe this transaction")
diff --git a/pacmanager/core/models.py b/pacmanager/core/models.py
index 9f94064..9151d8f 100644
--- a/pacmanager/core/models.py
+++ b/pacmanager/core/models.py
@@ -85,8 +85,8 @@ class Transaction(models.Model):
)
corporation = models.ForeignKey(Corporation, related_name='transactions')
- type = models.PositiveIntegerField(choices=TRANSACTION_TYPE_CHOICES)
- date = models.DateTimeField('Transaction Date', auto_now_add=True)
+ type = models.PositiveIntegerField(choices=TRANSACTION_TYPE_CHOICES, help_text="The type of transaction")
+ date = models.DateTimeField('Transaction Date', auto_now_add=True, help_text="The date/time the transaction was processed")
value = models.DecimalField('Transaction Value', max_digits=25, decimal_places=2)
comment = models.CharField(max_length=255)
@@ -97,8 +97,8 @@ class Key(models.Model):
"""EVE API Key"""
corporation = models.ForeignKey(Corporation, related_name='keys', blank=False, null=False)
- keyid = models.BigIntegerField('Key ID', primary_key=True)
- vcode = models.CharField('vCode', max_length=64)
+ keyid = models.BigIntegerField('Key ID', primary_key=True, help_text="Your EVE API key ID")
+ vcode = models.CharField('vCode', max_length=64, help_text="Your EVE API key vCode")
mask = models.BigIntegerField('Access Mask')
active = models.BooleanField('Active', default=True)
@@ -111,7 +111,6 @@ class Key(models.Model):
mask = 1 << bit
return (accessmask & mask) > 0
-
def save(self, *args, **kwargs):
self.update_api()
return super(Key, self).save(*args, **kwargs)
diff --git a/pacmanager/core/templates/core/corporation_contact.html b/pacmanager/core/templates/core/corporation_contact.html
index 92dae03..31d2e84 100644
--- a/pacmanager/core/templates/core/corporation_contact.html
+++ b/pacmanager/core/templates/core/corporation_contact.html
@@ -2,9 +2,7 @@
{% block content %}
Assign Corporation Contact
-
-Select the username of the contact you wish to assign to {{ object.name }}.
-
+Select the username of the contact you wish to assign to {{ object.name }}.
+{% else %}
+No corporations are currently available, consider adding a API key.
{% endif %}
{% endblock %}
diff --git a/pacmanager/core/templates/core/key_form.html b/pacmanager/core/templates/core/key_form.html
index 715d91a..d160c6e 100644
--- a/pacmanager/core/templates/core/key_form.html
+++ b/pacmanager/core/templates/core/key_form.html
@@ -1,16 +1,21 @@
{% extends "base.html" %}
{% block content %}
-{% if object %}Update{% else %}Add{% endif %} Key
+{% if object %}Update{% else %}Add{% endif %} EVE API Key
-
diff --git a/pacmanager/core/templates/core/key_list.html b/pacmanager/core/templates/core/key_list.html
index c99cbcc..167eec3 100644
--- a/pacmanager/core/templates/core/key_list.html
+++ b/pacmanager/core/templates/core/key_list.html
@@ -19,6 +19,8 @@
+{% else %}
+No keys are currently stored.
{% endif %}
Add Key
diff --git a/pacmanager/core/views.py b/pacmanager/core/views.py
index 66b093c..493b9ed 100644
--- a/pacmanager/core/views.py
+++ b/pacmanager/core/views.py
@@ -8,6 +8,7 @@ from django.views.generic import ListView, DetailView, CreateView, DeleteView, U
from django.views.generic.detail import SingleObjectMixin
from django.utils import simplejson as json
from django.contrib import messages
+from django.db.models import Sum
from eveapi import EVEAPIConnection, Error
from braces.views import LoginRequiredMixin, PermissionRequiredMixin
@@ -84,6 +85,13 @@ class CorporationListView(LoginRequiredMixin, ListView):
model = Corporation
paginate_by = 25
+ def get_context_data(self, **kwargs):
+ ctx = super(CorporationListView, self).get_context_data(**kwargs)
+ ctx.update({
+ 'total': self.get_queryset().filter(balance__lt=0).aggregate(Sum('balance'))['balance__sum'] or Decimal('0')
+ })
+ return ctx
+
def get_queryset(self):
if self.request.user.has_perm('core.view_all_corporation'):
return self.model.objects.all()
diff --git a/pacmanager/formtools/templates/formtools/formfield.html b/pacmanager/formtools/templates/formtools/formfield.html
index fca8d98..3dae8e3 100644
--- a/pacmanager/formtools/templates/formtools/formfield.html
+++ b/pacmanager/formtools/templates/formtools/formfield.html
@@ -7,7 +7,7 @@
{{ field.label_tag|add_class:"control-label" }}
{% if class %}{{ field|add_class:class }}{% else %}{{ field }}{% endif %}
- {% if field.help_text %}
{{ field.help_text }}{% endif %}
+ {% if field.help_text %}
{{ field.help_text }}
{% endif %}
{% if field.errors %}
{% for error in field.errors %}{{ error }}{% endfor %}{% endif %}
diff --git a/pacmanager/pacmanager/templates/base.html b/pacmanager/pacmanager/templates/base.html
index c53c709..b4eda7e 100644
--- a/pacmanager/pacmanager/templates/base.html
+++ b/pacmanager/pacmanager/templates/base.html
@@ -9,8 +9,10 @@