Commits

Chris Lasher committed 0e02f03 Draft

Removes trailing whitespace.

Comments (0)

Files changed (8)

 def get_month(request):
     """
     Returns the querystring 'date__month' parameter or the current month.
-    If it was not found then returns with `None`.  
+    If it was not found then returns with `None`.
     """
     try:
         return int(request.GET['date__month'])
                     'category',
                     'description',
                     'formatted_amount')
-    
+
     list_filter = ('user', 'date', 'category', )
     ordering = ('-date', )
 
             'types_stat' : types_stat,
             'current_year': year,
             'current_month': month,
-            'current_user_id': user_id, 
+            'current_user_id': user_id,
             'title': title,
             'media_dir': settings.MEDIA_URL + "/expense/"
         }
 
         return admin.ModelAdmin.changelist_view(self, request, extra_context)
-    
+
 admin.site.register(Expense, ExpenseAdmin)
 
 

expense/filterspec.py

 
         self.links = [(_('Any date'), {}),]
 
-        
+
         months = model.objects.get_months()
         for m in months:
             self.links.append(

expense/managers.py

         """
         types =  m.Type.objects.all()
         cat_filter = Q()
-        if user_id: 
+        if user_id:
             cat_filter = Q(expenses__user__id = user_id)
         if year:
             cat_filter = cat_filter & Q(expenses__date__year = year)
-        if month: 
+        if month:
             cat_filter =  cat_filter & Q(expenses__date__month = month)
 
         for t in types:
         recorded.
         """
         return m.Expense.objects.dates('date', 'year', order='DESC')
-       
+

expense/models.py

     name = models.CharField(_('name'), max_length=50)
     type = models.ForeignKey(Type, related_name='categories',
                              blank = False, null=True)
-    
+
     class Meta:
         verbose_name_plural = _('categories')
         verbose_name = _('category')
         ordering = ['type__name', 'name']
-        
+
     def __unicode__(self):
         return ("%s - %s" % (self.type.name,  self.name))
 
     date = models.DateField(_('date'), 'date')
     description = models.CharField(_('description'), max_length = 300)
     amount = models.IntegerField(_('amount'))
-    
+
     objects = ExpenseManager()
-    
+
     date.expense_date_filter =  True
     class Meta:
         verbose_name_plural = _('expenses')
         verbose_name = _('expense')
         ordering = ['-date', 'category__type__name', 'category__name']
-    
+
     def __unicode__(self):
         return self.description
 
 
     def tearDown(self):
         [obj.delete() for obj in Expense.objects.all()]
-        
+
     def testType(self):
         type = Type.objects.get(id = 1)
         self.assertEqual(type.id, 1)
         self.assertEqual(expense.description, 'expense')
         self.assertEqual(expense.amount, 100)
         self.assertEqual(expense.date, datetime.date(2011, 1, 5))
- 
+
 
 class ExpenseCalculationTestCase(TestCase):
     fixtures = ['users.xml', 'initial_data.json']
         # only 'category 2'
         self.failUnlessEqual(len(category_list), 1)
         self.failUnlessEqual(category_list[0].category_total, 100)
-       
-        
+
+
     def testYears(self):
         years = Expense.objects.get_years()
         self.failUnlessEqual(len(years), 1)
         self.failUnlessEqual(len(data), 1)
         self.failUnlessEqual(data[0]["data"], [[7, 0], [1, 0], [4, 0], [5, 0], [2, 0], [3, 0], [6, 0]])
         self.failUnlessEqual(data[0]["label"], u"super")
-        
+
 
 urlpatterns = patterns(
     'expense.views',
-    url(r'^bar_chart_data/(?P<user_id>\d+)/(?P<type>\d+)/(?P<year>\d+)/(?P<month>\d+)', 
+    url(r'^bar_chart_data/(?P<user_id>\d+)/(?P<type>\d+)/(?P<year>\d+)/(?P<month>\d+)',
         views.bar_chart_data),
-    url(r'^pie_chart_data/(?P<user_id>\d+)/(?P<type>\d+)/(?P<year>\d+)/(?P<month>\d+)', 
+    url(r'^pie_chart_data/(?P<user_id>\d+)/(?P<type>\d+)/(?P<year>\d+)/(?P<month>\d+)',
         views.pie_chart_data),
 )
 
     for c in expense_type.categories.all().order_by('name'):
         labels.append([index, c.name])
         index = index + 1
-    
+
     t = loader.get_template('admin/expense/expense/bar_chart.html')
     c = Context({
-        'media_dir': settings.MEDIA_URL + "/expense/", 
-        'type': expense_type.name, 
-        'year':  year, 
-        'month': month, 
+        'media_dir': settings.MEDIA_URL + "/expense/",
+        'type': expense_type.name,
+        'year':  year,
+        'month': month,
         'chart_data': simplejson.dumps(data),
-        'labels': simplejson.dumps(labels), 
+        'labels': simplejson.dumps(labels),
     })
     return HttpResponse(t.render(c))
-   
+
 def _get_bar_chart_data(type, user_id=None, year = None, month = None):
     results = []
     users = []
     q = Q()
     if year and int(year) > 0:
         q = q & Q(date__year = year)
-    if month and int(month) > 0: 
+    if month and int(month) > 0:
         q =  q & Q(date__month = month)
 
-    if user_id and int(user_id) > 0: 
+    if user_id and int(user_id) > 0:
         users.append(User.objects.get(id=user_id));
     else:
         users = User.objects.all()
     data =  _get_pie_chart_data(expense_type, user_id, year, month)
     t = loader.get_template('admin/expense/expense/pie_chart.html')
     c = Context({
-        'media_dir': settings.MEDIA_URL + "/expense/", 
-        'type': expense_type.name, 
-        'year':  year, 
-        'month': month, 
+        'media_dir': settings.MEDIA_URL + "/expense/",
+        'type': expense_type.name,
+        'year':  year,
+        'month': month,
         'chart_data': simplejson.dumps(data),
     })
     return HttpResponse(t.render(c))
         q = q & Q(expenses__date__year = year)
     if month and int(month) > 0:
         q = q & Q(expenses__date__month = month)
-    
+
     #calculate values
-    
+
     type.category_list = type.categories.filter(q).annotate(
         category_total = Sum('expenses__amount'))
 
     return results
 
 
-    
+
       author_email='szunyog@gmail.com',
       url='https://bitbucket.org/szunyog/django-expense/',
       packages=['expense','expense.templatetags'],
-      package_data = {'expense' : files }, 
+      package_data = {'expense' : files },
       classifiers=['Development Status :: 4 - Beta',
                    'Environment :: Web Environment',
                    'Intended Audience :: Developers',