You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
from mongoengine import *
|
|
|
|
from models.Union import Union
|
|
from restapi import Methods
|
|
|
|
|
|
class Group(Document):
|
|
meta = {
|
|
'index_background': True,
|
|
'index_cls': False,
|
|
'auto_create_index': True,
|
|
'can_query': True,
|
|
'with_sub_docs': True,
|
|
'methods': [Methods.Get, Methods.List, Methods.Create],
|
|
"indexes": [
|
|
('name'),
|
|
("-name"),
|
|
("union","deleted"),
|
|
("union","deleted","name"),
|
|
],
|
|
}
|
|
union = ReferenceField(Union)
|
|
name = StringField(required=True)
|
|
rights = ListField(StringField(), required=True)
|
|
deleted = BooleanField(default=False)
|
|
|
|
def __unicode__(self):
|
|
return "{} {}".format(self.union.name, self.name)
|
|
|
|
|
|
class PaymentGroup(Document):
|
|
meta = {
|
|
'index_background': True,
|
|
'index_cls': False,
|
|
'auto_create_index': True,
|
|
'can_query': True,
|
|
'with_sub_docs': True,
|
|
'methods': [Methods.Get, Methods.List, Methods.Create],
|
|
"indexes": [
|
|
('name'),
|
|
("-name"),
|
|
("union"),
|
|
('union','name',"deleted")
|
|
],
|
|
}
|
|
union = ReferenceField(Union)
|
|
name = StringField(required=True)
|
|
deleted = BooleanField(default=False)
|
|
discount_percent = IntField(required=True)
|
|
|
|
def __unicode__(self):
|
|
return "{} {}".format(self.union.name, self.name)
|
|
|