diff options
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 |
commit | 270d2a3735ec65b58bdb23678aaede1b0ff90b7d (patch) | |
tree | e6da7c67ae8c7a624cbb49399ae9f8b45be8ea30 /archaeological_operations/models.py | |
parent | 4158b9a7119cd4ba4ddbfc2c92752d94c423a65b (diff) | |
download | Ishtar-270d2a3735ec65b58bdb23678aaede1b0ff90b7d.tar.bz2 Ishtar-270d2a3735ec65b58bdb23678aaede1b0ff90b7d.zip |
New migrations: add views
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 18 |
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) |