summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_files/tests.py20
-rw-r--r--ishtar_common/models.py7
2 files changed, 23 insertions, 4 deletions
diff --git a/archaeological_files/tests.py b/archaeological_files/tests.py
index 60f447c62..8a1069d51 100644
--- a/archaeological_files/tests.py
+++ b/archaeological_files/tests.py
@@ -25,7 +25,7 @@ from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test.client import Client
-from ishtar_common.tests import TestCase, COMMON_FIXTURES
+from ishtar_common.tests import TestCase, COMMON_FIXTURES, create_superuser
from ishtar_common.models import Town, IshtarSiteProfile
from archaeological_files import models
@@ -271,3 +271,21 @@ class FileOperationTest(TestCase, OperationInitTest, FileInit):
q = ParcelOwner.objects.filter(parcel__operation=self.operation,
parcel__parcel_number='42')
self.assertEqual(q.count(), 1)
+
+
+class DashboardTest(TestCase, FileInit):
+ fixtures = FILE_TOWNS_FIXTURES
+ model = models.File
+
+ def setUp(self):
+ self.username, self.password, self.user = create_superuser()
+ IshtarSiteProfile.objects.create()
+ self.create_file()
+
+ def test_dashboard(self):
+ url = 'dashboard-file'
+ c = Client()
+ c.login(username=self.username, password=self.password)
+
+ response = c.get(reverse(url))
+ self.assertEqual(response.status_code, 200)
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 19f557511..b2c45c86f 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1409,7 +1409,8 @@ class DashboardFormItem(object):
q = cls.objects.filter(**{date_var + '__isnull': False})
if fltr:
q = q.filter(**fltr)
- return q.filter(**{date_var + '__year': year}).distinct('pk')
+ return q.filter(
+ **{date_var + '__year': year}).order_by('pk').distinct('pk')
@classmethod
def get_by_month(cls, year, month, fltr={}, date_source='creation'):
@@ -1419,14 +1420,14 @@ class DashboardFormItem(object):
q = q.filter(**fltr)
q = q.filter(
**{date_var + '__year': year, date_var + '__month': month})
- return q.distinct('pk')
+ return q.order_by('pk').distinct('pk')
@classmethod
def get_total_number(cls, fltr={}):
q = cls.objects
if fltr:
q = q.filter(**fltr)
- return q.distinct('pk').count()
+ return q.order_by('pk').distinct('pk').count()
class Dashboard(object):