@@ -59,9 +59,6 @@ def get_item_from_tdbms(kind, id, params):
59
59
'time' : '{} sec' .format ((time_after - time_before ).total_seconds ())
60
60
}
61
61
62
- print colored (info , 'red' , 'on_grey' )
63
-
64
-
65
62
status = response .status_code
66
63
67
64
if status == 200 :
@@ -194,7 +191,7 @@ def get_ac(cls, ac_id=None):
194
191
student_info = get_item_from_tdbms ('student' ,
195
192
student ['studentId' ], ['name' , 'surname' , 'profileImageUrl' ])
196
193
del (student ['studentId' ])
197
- student [ 'student' ] = student_info
194
+ student . update ( student_info )
198
195
199
196
populated_students .append (student )
200
197
@@ -487,8 +484,6 @@ def post_mark(cls, mark):
487
484
# If mark has the required format:
488
485
if cls .validate_mark (mark ):
489
486
490
- print colored ('Posted mark' )
491
- print colored (mark , 'red' )
492
487
493
488
# Is created the object
494
489
enrollment = mark ['enrollment' ]
@@ -531,8 +526,6 @@ def update_mark(cls, mark_id, received_mark):
531
526
532
527
if cls .validate_mark (received_mark ):
533
528
534
- print colored ('Posted mark' )
535
- print colored (received_mark , 'red' )
536
529
537
530
# Is created the object
538
531
enrollment = received_mark ['enrollment' ]
@@ -595,8 +588,8 @@ def validate_dn(cls, disciplinary_note):
595
588
"""
596
589
Validate the format of item based of data store model.
597
590
598
- :param disciplinary_note: Item dict.
599
- :return: True if format is ok and false in other hand.
591
+ :param disciplinary_note: data block, dict.
592
+ :return: True if format is ok and false in other hand, boolean .
600
593
"""
601
594
# TODO: Implement.
602
595
return True
@@ -768,4 +761,43 @@ def delete_dn(cls, disciplinary_note):
768
761
return {'status' : 200 , 'data' : None , 'log' : None }
769
762
770
763
else : # If it doesn't exists:
771
- return {'status' : 404 , 'data' : None , 'log' : 'Disciplinary Note required seem like doesn\' t exists or was deleted.' }
764
+ return {'status' : 404 , 'data' : None , 'log' : 'Disciplinary Note required seem like doesn\' t exists or was deleted.' }
765
+
766
+ @classmethod
767
+ def cru_dn_schema (cls , schema , action ):
768
+ """
769
+ Do all functionality about schemas (all together because is very simple).
770
+ :param schema: Dict, data block to work with it.
771
+ :param action: String, action (HTTP verb) to realise with the singleton shema
772
+ in the database.
773
+ :return: Standard info dict (without data, only status code)
774
+ """
775
+
776
+ if action == 'GET' and not schema :
777
+ dn_options_saved = DNOptions .get_by_id ('dn_options_saved' )
778
+ if not dn_options_saved :
779
+ DNOptions .get_or_insert ('dn_options_saved' ,
780
+ kinds = [OptionItem (id = 1 , meaning = 'Tipo base' )],
781
+ gravities = [OptionItem (id = 1 , meaning = 'Gravedad base' )])
782
+ dn_options_saved = DNOptions .get_by_id ('dn_options_saved' )
783
+ return {'status' : 200 , 'data' : dn_options_saved .to_dict (), 'log' : None }
784
+
785
+ if action == 'PUT' and schema :
786
+
787
+ kinds = []
788
+ gravities = []
789
+ for kind in schema ['kinds' ]:
790
+ kinds .append (OptionItem (id = kind ['id' ], meaning = kind ['meaning' ]))
791
+
792
+ for gravity in schema ['gravities' ]:
793
+ gravities .append (OptionItem (id = gravity ['id' ], meaning = gravity ['meaning' ]))
794
+
795
+ dn_options_saved = DNOptions .get_or_insert ('dn_options_saved' )
796
+
797
+ dn_options_saved .kinds = kinds
798
+ dn_options_saved .gravities = gravities
799
+ dn_options_saved .modifiedAt = time_now ()
800
+
801
+ dn_options_saved .put ()
802
+
803
+ return {'status' : 200 , 'data' : dn_options_saved .to_dict (), 'log' : None }
0 commit comments