29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
|
# HG changeset patch
|
||
|
# Parent 8d5573b704b2867788dd6895503f1871c2976a29
|
||
|
|
||
|
Index: doc-backend/openacademy/course.py
|
||
|
===================================================================
|
||
|
--- doc-backend.orig/openacademy/course.py 2014-08-22 17:01:50.147102793 +0200
|
||
|
+++ doc-backend/openacademy/course.py 2014-08-22 17:01:50.139102793 +0200
|
||
|
@@ -39,3 +39,20 @@
|
||
|
else:
|
||
|
self.taken_seats = 100.0 * len(self.attendee_ids) / self.seats
|
||
|
|
||
|
+ @api.onchange('seats', 'attendee_ids')
|
||
|
+ def _verify_valid_seats(self):
|
||
|
+ if self.seats < 0:
|
||
|
+ return {
|
||
|
+ 'warning': {
|
||
|
+ 'title': "Incorrect 'seats' value",
|
||
|
+ 'message': "The number of available seats may not be negative",
|
||
|
+ },
|
||
|
+ }
|
||
|
+ if self.seats < len(self.attendee_ids):
|
||
|
+ return {
|
||
|
+ 'warning': {
|
||
|
+ 'title': "Too many attendees",
|
||
|
+ 'message': "Increase seats or remove excess attendees",
|
||
|
+ },
|
||
|
+ }
|
||
|
+
|