settings.py 3.9 KB
Newer Older
1
2
3
4
5
"""Data Model and General Configuration of Eve.

Check out [the Eve docs for configuration](http://python-eve.org/config.html)
if you are unsure about some of the settings.
"""
adietmue's avatar
adietmue committed
6
7
8
9

# AMIVAPI URL and Admin Group
AMIVAPI_URL = "https://amiv-api.ethz.ch"
ADMIN_GROUP_NAME = 'PVK Admins'
10
11
12
13
14
15
16
17

# DB
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_USERNAME = 'pvkuser'
MONGO_PASSWORD = 'pvkpass'
MONGO_DBNAME = 'pvk'

adietmue's avatar
adietmue committed
18

19
RESOURCE_METHODS = ['GET', 'POST']
adietmue's avatar
adietmue committed
20
21
ITEM_METHODS = ['GET', 'PATCH', 'DELETE']

22

adietmue's avatar
adietmue committed
23
24
# ISO 8601 time format instead of rfc1123
DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
25

adietmue's avatar
adietmue committed
26

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# A schema for required start/end time tuple
TIMESPAN = {
    'type': 'dict',
    'schema': {
        'start': {
            'type': 'datetime',
            'nullable': False,
            'required': True,
        },
        'end': {
            'type': 'datetime',
            'nullable': False,
            'required': True,
        },
    },
}


# Resources
DOMAIN = {
    'lectures': {
        'schema': {
            'title': {
                'type': 'string',
                'maxlength': 100,
                'unique': True,
                'required': True,
                'nullable': False,
                'empty': False,
            },
            'department': {
                'type': 'string',
                'allowed': ['itet', 'mavt'],
                'required': True,
                'nullable': False,
            },
            'year': {
                'type': 'integer',
                'min': 1,
                'max': 3,
                'required': True
            },
        },
    },

    'assistants': {
        'schema': {
            'nethz': {
                'type': 'string',
                'maxlength': 10,
                'unique': True,
                'empty': False,
                'nullable': False,
                'required': True,
            },
            'name': {
                'type': 'string',
                'readonly': True,
            },
        },
    },
    'courses': {
        'schema': {
            'lecture': {
                'type': 'objectid',
                'data_relation': {
                    'resource': 'lectures',
                    'field': '_id',
                    'embeddable': True
                },
97
                'not_patchable': True,  # Course is tied to lecture
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
            },
            'assistant': {
                'type': 'objectid',
                'data_relation': {
                    'resource': 'assistants',
                    'field': '_id',
                    'embeddable': True
                },
            },

            'signup': TIMESPAN,

            'datetimes': {
                'type': 'list',
                'schema': TIMESPAN,
            },
            'room': {
                'type': 'string',
                'maxlength': 100,
                'unique': True,
                'required': True,
                'nullable': False,
                'empty': False,
            },
            'spots': {
                'type': 'integer',
                'min': 1,
                'required': True,
                'nullable': False
            }
        },
    },

    'signups': {
        'schema': {
            'nethz': {
                'type': 'string',
                'maxlength': 10,
                'empty': False,
                'nullable': False,
                'required': True,
adietmue's avatar
adietmue committed
139
                'only_own_nethz': True,
140
                'not_patchable': True,  # Signup is tied to user
141
142
143
144
145
146
147
148
            },
            'course': {
                'type': 'objectid',
                'data_relation': {
                    'resource': 'courses',
                    'field': '_id',
                    'embeddable': True
                },
adietmue's avatar
adietmue committed
149
                'unique_combination': ['nethz'],
150
151
152
153
154
155
156
157
158
            },
            'status': {
                'type': 'string',
                'allowed': ['waiting', 'accepted', 'accepted+paid'],
                'readonly': True,
            },
        },
    }
}