summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-04-18 22:59:43 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-04-18 22:59:43 +0200
commite886e8a1a79880bed9cd0ec480a0658ae93ad400 (patch)
treee6da7c67ae8c7a624cbb49399ae9f8b45be8ea30 /archaeological_operations/models.py
parentc5571208a3d7a50d24226132d6ff77f8edd03921 (diff)
downloadIshtar-e886e8a1a79880bed9cd0ec480a0658ae93ad400.tar.bz2
Ishtar-e886e8a1a79880bed9cd0ec480a0658ae93ad400.zip
New migrations: add views
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index bebeba240..0548c92e4 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2012-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2012-2017 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -844,6 +844,22 @@ class OperationByDepartment(models.Model):
"""
Database view for dashboard
"""
+ CREATE_SQL = """
+ CREATE VIEW operation_department (id, department_id, operation_id) as
+ select town."id", town."departement_id",
+ operation_towns."operation_id"
+ from ishtar_common_town town
+ inner join archaeological_operations_operation_towns
+ operation_towns
+ on operation_towns."town_id"=town."id"
+ order by town."departement_id";
+ CREATE RULE operation_department_delete
+ AS ON DELETE TO operation_department DO INSTEAD();
+ """
+ DELETE_SQL = """
+ DROP VIEW operation_department;
+ """
+
operation = models.ForeignKey(Operation, verbose_name=_(u"Operation"))
department = models.ForeignKey(Department, verbose_name=_(u"Department"),
blank=True, null=True)