root / snf-astakos-app / astakos / quotaholder_app / models.py @ f6ff3033
History | View | Annotate | Download (3.3 kB)
1 | ea1e5d9f | Giorgos Korfiatis | # Copyright 2012, 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 3e5941c1 | Giorgos Korfiatis | #
|
3 | 3e5941c1 | Giorgos Korfiatis | # Redistribution and use in source and binary forms, with or
|
4 | 3e5941c1 | Giorgos Korfiatis | # without modification, are permitted provided that the following
|
5 | 3e5941c1 | Giorgos Korfiatis | # conditions are met:
|
6 | 3e5941c1 | Giorgos Korfiatis | #
|
7 | 3e5941c1 | Giorgos Korfiatis | # 1. Redistributions of source code must retain the above
|
8 | 3e5941c1 | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
9 | 3e5941c1 | Giorgos Korfiatis | # disclaimer.
|
10 | 3e5941c1 | Giorgos Korfiatis | #
|
11 | 3e5941c1 | Giorgos Korfiatis | # 2. Redistributions in binary form must reproduce the above
|
12 | 3e5941c1 | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
13 | 3e5941c1 | Giorgos Korfiatis | # disclaimer in the documentation and/or other materials
|
14 | 3e5941c1 | Giorgos Korfiatis | # provided with the distribution.
|
15 | 3e5941c1 | Giorgos Korfiatis | #
|
16 | 3e5941c1 | Giorgos Korfiatis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 3e5941c1 | Giorgos Korfiatis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 3e5941c1 | Giorgos Korfiatis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 3e5941c1 | Giorgos Korfiatis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 3e5941c1 | Giorgos Korfiatis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 3e5941c1 | Giorgos Korfiatis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 3e5941c1 | Giorgos Korfiatis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 3e5941c1 | Giorgos Korfiatis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 3e5941c1 | Giorgos Korfiatis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 3e5941c1 | Giorgos Korfiatis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 3e5941c1 | Giorgos Korfiatis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 3e5941c1 | Giorgos Korfiatis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 3e5941c1 | Giorgos Korfiatis | #
|
29 | 3e5941c1 | Giorgos Korfiatis | # The views and conclusions contained in the software and
|
30 | 3e5941c1 | Giorgos Korfiatis | # documentation are those of the authors and should not be
|
31 | 3e5941c1 | Giorgos Korfiatis | # interpreted as representing official policies, either expressed
|
32 | 3e5941c1 | Giorgos Korfiatis | # or implied, of GRNET S.A.
|
33 | 3e5941c1 | Giorgos Korfiatis | |
34 | 164e64d5 | Giorgos Korfiatis | from django.db.models import (Model, BigIntegerField, CharField, DateTimeField, |
35 | c11dc0ce | Giorgos Korfiatis | ForeignKey, AutoField) |
36 | 9f1a1bd0 | Georgios D. Tsoukalas | |
37 | 15e727f1 | Giorgos Korfiatis | |
38 | 9f1a1bd0 | Georgios D. Tsoukalas | class Holding(Model): |
39 | 9f1a1bd0 | Georgios D. Tsoukalas | |
40 | 15e727f1 | Giorgos Korfiatis | holder = CharField(max_length=4096, db_index=True) |
41 | 15e727f1 | Giorgos Korfiatis | source = CharField(max_length=4096, null=True) |
42 | 15e727f1 | Giorgos Korfiatis | resource = CharField(max_length=4096, null=False) |
43 | 9f1a1bd0 | Georgios D. Tsoukalas | |
44 | 41e92ef2 | Giorgos Korfiatis | limit = BigIntegerField() |
45 | 41e92ef2 | Giorgos Korfiatis | usage_min = BigIntegerField(default=0)
|
46 | 41e92ef2 | Giorgos Korfiatis | usage_max = BigIntegerField(default=0)
|
47 | 9f1a1bd0 | Georgios D. Tsoukalas | |
48 | 9f1a1bd0 | Georgios D. Tsoukalas | class Meta: |
49 | 2864e701 | Giorgos Korfiatis | unique_together = (('holder', 'source', 'resource'),) |
50 | 9f1a1bd0 | Georgios D. Tsoukalas | |
51 | 9f1a1bd0 | Georgios D. Tsoukalas | |
52 | 9f1a1bd0 | Georgios D. Tsoukalas | class Commission(Model): |
53 | 9f1a1bd0 | Georgios D. Tsoukalas | |
54 | 15e727f1 | Giorgos Korfiatis | serial = AutoField(primary_key=True)
|
55 | f6e7a826 | Giorgos Korfiatis | name = CharField(max_length=4096, default="") |
56 | 15e727f1 | Giorgos Korfiatis | clientkey = CharField(max_length=4096, null=False) |
57 | 164e64d5 | Giorgos Korfiatis | issue_datetime = DateTimeField() |
58 | 15e727f1 | Giorgos Korfiatis | |
59 | 9f1a1bd0 | Georgios D. Tsoukalas | |
60 | 9f1a1bd0 | Georgios D. Tsoukalas | class Provision(Model): |
61 | 9f1a1bd0 | Georgios D. Tsoukalas | |
62 | 15e727f1 | Giorgos Korfiatis | serial = ForeignKey(Commission, |
63 | 15e727f1 | Giorgos Korfiatis | to_field='serial',
|
64 | 15e727f1 | Giorgos Korfiatis | related_name='provisions')
|
65 | 15e727f1 | Giorgos Korfiatis | holder = CharField(max_length=4096, db_index=True) |
66 | 15e727f1 | Giorgos Korfiatis | source = CharField(max_length=4096, null=True) |
67 | 15e727f1 | Giorgos Korfiatis | resource = CharField(max_length=4096, null=False) |
68 | 6c0f4562 | Giorgos Korfiatis | |
69 | 41e92ef2 | Giorgos Korfiatis | quantity = BigIntegerField() |
70 | 9f1a1bd0 | Georgios D. Tsoukalas | |
71 | 79e3da8a | Giorgos Korfiatis | def todict(self): |
72 | 6c0f4562 | Giorgos Korfiatis | return {'holder': self.holder, |
73 | 6c0f4562 | Giorgos Korfiatis | 'source': self.source, |
74 | 6c0f4562 | Giorgos Korfiatis | 'resource': self.resource, |
75 | 79e3da8a | Giorgos Korfiatis | 'quantity': self.quantity, |
76 | 79e3da8a | Giorgos Korfiatis | } |
77 | 79e3da8a | Giorgos Korfiatis | |
78 | 6c0f4562 | Giorgos Korfiatis | def holding_key(self): |
79 | 6c0f4562 | Giorgos Korfiatis | return (self.holder, self.source, self.resource) |
80 | 6c0f4562 | Giorgos Korfiatis | |
81 | 79e3da8a | Giorgos Korfiatis | |
82 | f590f930 | Georgios D. Tsoukalas | class ProvisionLog(Model): |
83 | f590f930 | Georgios D. Tsoukalas | |
84 | 15e727f1 | Giorgos Korfiatis | serial = BigIntegerField() |
85 | f6e7a826 | Giorgos Korfiatis | name = CharField(max_length=4096)
|
86 | c3b42b86 | Giorgos Korfiatis | issue_time = CharField(max_length=4096)
|
87 | c3b42b86 | Giorgos Korfiatis | log_time = CharField(max_length=4096)
|
88 | 15e727f1 | Giorgos Korfiatis | holder = CharField(max_length=4096)
|
89 | 15e727f1 | Giorgos Korfiatis | source = CharField(max_length=4096, null=True) |
90 | 15e727f1 | Giorgos Korfiatis | resource = CharField(max_length=4096)
|
91 | 41e92ef2 | Giorgos Korfiatis | limit = BigIntegerField() |
92 | 41e92ef2 | Giorgos Korfiatis | usage_min = BigIntegerField() |
93 | 41e92ef2 | Giorgos Korfiatis | usage_max = BigIntegerField() |
94 | 41e92ef2 | Giorgos Korfiatis | delta_quantity = BigIntegerField() |
95 | 15e727f1 | Giorgos Korfiatis | reason = CharField(max_length=4096) |