-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedu.py
1522 lines (1081 loc) · 47.8 KB
/
edu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
97
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Justice Ndou'
__website__ = 'http://jobcloud.freelancing-seo.com/'
__email__ = '[email protected]'
# Copyright 2014 Freelancing Solutions.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#The Address Records will stay by themselves on the address class that inherits from Physical Address and contact Details
#The Person Record will have private information class and address class plus Contact Details (Contact details are contained inside the address
#The Profile Record will inherit the person record and add Educational Qualifications and skills of the person
#The Portfolio Record will inherit the profile record and add the users portfolio that also links to external portfolios
#The freelancer Record will have the Portfolio record plus added functionality to submit and bid on freelance jobs
#The Jobs Record will take the Portfolio record and add functionality to submit jobs and also apply for jobs
# The jobs record can also be called the employer record.
#The complete Record will combine the freelancer record and the Jobs record.
###########END OF THE PERSON RECORD##############################################################
#################################################################################################
#################################################################################################
#To create the profile record we need to create complete educational and skills records##########
#################################################################################################
#################################################################################################
from datatypes import Reference, PhysicalAddress, ContactDetails, Names, Private_info, Address, LegalYearLimit
import datetime
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.api import memcache
from ConstantsAndErrorCodes import MyConstants, ErrorCodes
import logging
#This class defines a high school
class HighSchool (db.Expando, MyConstants, ErrorCodes):
_minSchoolNameLen = 2
_maxSchoolNameLen = 256
_SchoolPhysicalAddress = PhysicalAddress()
_SchoolContactDetails = ContactDetails()
_contactPersonAccount = Reference()
_contactPersonNames = Names()
_contactPersonPrivateInfo = Private_info()
_SchoolRecordCreator = Reference()
# The ownership of subclasses contact details and physical address classes will be taken by contact person
#from the reference class this Reference classes can be selected by their collection names
strSchoolName = db.StringProperty()
IndexSchoolRecordCreator = db.ReferenceProperty(Reference, collection_name='high_school_collection_owner')
IndexSchoolPhysicalAddress = db.ReferenceProperty(PhysicalAddress, collection_name='high_school_collection')
IndexSchoolContactDetails = db.ReferenceProperty(ContactDetails, collection_name='high_school_collection')
IndexContactPersonAccount = db.ReferenceProperty(Reference, collection_name='high_school_collection')
IndexContactPersonNames = db.ReferenceProperty(Names, collection_name='high_school_collection')
IndexContactPersonPrivateInf = db.ReferenceProperty(Private_info, collection_name='high_school_collection')
isValid = db.BooleanProperty(default=False)
isVerified = db.BooleanProperty(default=False) #Verification of the School Existence, We can do from other Social Networks such as Facebook
DateCreated = db.DateTimeProperty(auto_now_add=True)
DateTimeModified = db.DateTimeProperty(auto_now=True)
DateVerified = db.DateTimeProperty()
# Date Verified must be written in this format
'''
class Book(db.Model):
title = db.StringProperty(required=True)
author = db.StringProperty(required=True)
copyright_year = db.IntegerProperty()
author_birthdate = db.DateProperty()
obj = Book(title='The Grapes of Wrath',
author='John Steinbeck')
obj.copyright_year = 1939
obj.author_birthdate = datetime.date(1902, 2, 27)
'''
def readIsValid(self):
try:
if self.setIsValid():
return self.isValid
else:
return self.undefined
except:
return self._generalError
def setIsValid(self):
try:
if (self.IndexContactPersonAccount == self.undefined) and (self.IndexSchoolRecordCreator == self.undefined) and (self.IndexContactPersonNames == self.undefined) and (self.strSchoolName == self.undefined):
self.isValid = True
return True
else:
self.isValid = False
return True
except:
return False
# Read is verified must check to see if the verification process is complete once its not complete notify the
# user and
# check to see when was the last time the verification email or sms was sent if its more than seven days then send
# it again by calling set is verified
#TODO FINISH UP READ IS VERIFIED
def readIsVerified(self):
pass
# set is verified must actually call initiate the verification function such as sending a verification email to the school email address
# once this function finishes running, it must exit.
#TODO FINISH UP SET IS VERIFIED
def setIsVerified(self):
pass
#TODO FINISH UP WRITE DATE VERIFIED
def writeDateVerified(self, strinput):
pass
def readSchoolRecordCreator(self):
try:
if not(self.IndexSchoolRecordCreator == self.undefined):
return self.IndexSchoolRecordCreator
else:
return self.undefined
except:
return self._generalError
def writeSchoolRecordCreator(self, strinput):
try:
Guser = users.get_current_user()
if Guser:
strinput = str(strinput)
strinput = strinput.strip()
if strinput.isalnum():
self.IndexSchoolRecordCreator = strinput
return True
else:
self.IndexSchoolRecordCreator = self.undefined
return False
else:
return self._userNotLoggedin
except:
return self._generalError
def retrieveRecordCreator(self):
try:
if not(self.IndexSchoolRecordCreator == self.undefined):
tCreator = Reference.get(self.IndexSchoolRecordCreator())
if tCreator.readIsValid():
self._SchoolRecordCreator = tCreator
return tCreator
else:
return self.undefined
else:
return self._clsReferenceDonotExist
except:
return self._generalError
#Save Record Creator cannot create a new record but can only update an existing one
def saveRecordCreator(self):
try:
Guser = users.get_current_user()
if Guser:
findquery = db.Query(Reference).filter('strReference =', Guser.user_id())
results = findquery.fetch(limit=self._maxQResults)
if len(results) > 0:
result = results[0]
dRef = Reference.get(result.key())
if dRef.readReference() == self._SchoolRecordCreator.readReference():
dRef.writeIDNumber(self._SchoolRecordCreator.readIDNumber())
dRef.writeDateTimeVerified(self._SchoolRecordCreator.readDatetimeVerified())
dRef.writeIsUserVerified(self._SchoolRecordCreator.readIsUserVerified())
dRef.writeLogoPhoto(self._SchoolRecordCreator.readLogoPhoto())
dRef.writePassword(self._SchoolRecordCreator.readPassword())
dRef.writeReference(self._SchoolRecordCreator.readReference())
dRef.writeUsername(self._SchoolRecordCreator.readUsername())
dRef.writeVerEmail(self._SchoolRecordCreator.readVerEmail())
self.clsSchoolRecordCreator = dRef.put()
return self.clsSchoolRecordCreator()
else:
return self._UserNotAuthorised
else:
return self._clsReferenceDonotExist
else:
return self._userNotLoggedin
except:
return self._generalError
def readSchoolName(self):
try:
logging.info('READ SCHOOL NAME WAS CALLED')
temp = str(self.strSchoolName)
temp = temp.strip()
temp = temp.title()
if len(temp) > 0:
return temp
else:
return self.undefined
except:
return self._generalError
def writeSchoolName(self, strinput):
try:
Guser = users.get_current_user()
if Guser:
strinput = str(strinput)
strinput = strinput.strip()
strinput = strinput.lower()
if (len(strinput) <= self._maxSchoolNameLen) and (len(strinput) >= self._minSchoolNameLen):
self.strSchoolName = strinput
return True
else:
self.strSchoolName = self.undefined
return False
else:
return self._userNotLoggedin
except:
return self._generalError
def readPhysicalAddress(self):
try:
temp = str(self.IndexSchoolPhysicalAddress)
temp = temp.strip()
if temp.isalnum():
return temp
else:
return self.undefined
except:
return self._generalError
def writePhysicalAddress(self, strinput):
try:
temp = str(strinput)
logging.info('WRITE PHYSICAL ADDRESS EXECUTED: ' + temp)
if len(temp) > 0:
self.IndexSchoolPhysicalAddress = strinput
return True
else:
logging.info('SHOWING FALSE ON WRITING PHYSICAL ADRESS')
return False
except:
logging.info('THROWING EXCEPTIONS')
return self._generalError
def retrievePhysicalAddress(self):
try:
if not(self.IndexSchoolPhysicalAddress() == self.undefined):
tPhysAddress = PhysicalAddress.get(self.IndexPhysicalAddress())
if tPhysAddress.readIsValid():
return tPhysAddress
else:
return self.undefined
else:
return self._clsPhysicalDonotExist
except:
return self._generalError
def savePhysicalAddress(self):
try:
Guser = users.get_current_user()
if Guser:
if self._SchoolPhysicalAddress.readIsValid():
if self.IndexSchoolPhysicalAddress() == self.undefined:
self.IndexSchoolPhysicalAddress = self._SchoolPhysicalAddress.put()
return self.IndexSchoolPhysicalAddress()
else:
tPhysical = PhysicalAddress.get(self.IndexSchoolPhysicalAddress())
if tPhysical.readIsValid():
tPhysical.writeCityTown(self._SchoolPhysicalAddress.readCityTown())
tPhysical.writeCountry(self._SchoolPhysicalAddress.readCountry())
tPhysical.writePostalZipCode(self._SchoolPhysicalAddress.readPostalZipCode())
tPhysical.writeProvinceState(self._SchoolPhysicalAddress.readProvinceState())
tPhysical.writeStandNumber(self._SchoolPhysicalAddress.readStandNumber())
tPhysical.writeStreetName(self._SchoolPhysicalAddress.readStreetName())
self.IndexSchoolPhysicalAddress = tPhysical.put()
return self.IndexSchoolPhysicalAddress()
else:
return self._PhysicalAddressINvalid
else:
return self._PhysicalAddressINvalid
else:
return self._userNotLoggedin
except:
return self._generalError
def readContactDetails(self):
try:
if not(self.IndexSchoolContactDetails == self.undefined):
return self.IndexSchoolContactDetails
else:
return self.undefined
except:
return self._generalError
def writeContactDetails(self, strinput):
try:
Guser = users.get_current_user()
if Guser:
strinput = str(strinput)
strinput = strinput.strip()
if strinput.isalnum():
self.IndexSchoolContactDetails = strinput
return True
else:
self.IndexSchoolContactDetails = self.undefined
return False
else:
return self._userNotLoggedin
except:
return self._generalError
def retrieveContactDetails(self):
try:
if not(self.IndexSchoolContactDetails == self.undefined):
return self.IndexSchoolContactDetails
else:
return self.undefined
except:
return self._generalError
def saveContactDetails(self):
try:
Guser = users.get_current_user()
if Guser:
if self._SchoolContactDetails.readIsValid():
if self.IndexSchoolContactDetails == self.undefined:
tempkey = self._SchoolContactDetails.put()
if self.writeContactDetails(tempkey):
return tempkey
else:
return self.undefined
else:
tSchoolContacts = ContactDetails.get(self.IndexSchoolContactDetails())
if tSchoolContacts.readIsValid():
tSchoolContacts.writeAboutMe(self._SchoolContactDetails.readAboutMe())
tSchoolContacts.writeBlog(self._SchoolContactDetails.readBlog())
tSchoolContacts.writeCell(self._SchoolContactDetails.readCell())
tSchoolContacts.writeEmail(self._SchoolContactDetails.readEmail())
tSchoolContacts.writeFacebook(self._SchoolContactDetails.readFacebook())
tSchoolContacts.writeFax(self._SchoolContactDetails.readFax())
tSchoolContacts.writeGooglePlus(self._SchoolContactDetails.readGooglePlus())
tSchoolContacts.writeLinkedIn(self._SchoolContactDetails.readLinkedIn())
tSchoolContacts.writePinterest(self._SchoolContactDetails.readPinterest())
tSchoolContacts.writeSkype(self._SchoolContactDetails.readSkype())
tSchoolContacts.writeTel(self._SchoolContactDetails.readTel())
tSchoolContacts.writeTwitter(self._SchoolContactDetails.readTwitter())
tSchoolContacts.writeWebsite(self._SchoolContactDetails.readWebsite())
tSchoolContacts.writeWhosWho(self._SchoolContactDetails.readWhosWho())
tempkey = tSchoolContacts.put()
if self.writeContactDetails(tempkey):
return tempkey
else:
return self.undefined
else:
return self._ContactDetailsInvalid
else:
return self._ContactDetailsInvalid
else:
return self._userNotLoggedin
except:
return self._generalError
def readContactPerson(self):
try:
if not(self.IndexContactPersonAccount == self.undefined):
return self.IndexContactPersonAccount
else:
return self._SchoolContactPersonDoNotExist
except:
return self._generalError
def writeContactPerson(self, strinput):
try:
Guser = users.get_current_user()
if Guser:
strinput = str(strinput)
strinput = strinput.strip()
Tref = Reference.get(strinput)
if Tref.readIsValid():
self.IndexContactPersonAccount = Tref.key()
return True
else:
self.IndexContactPersonAccount = self.undefined
return False
else:
return self._userNotLoggedin
except:
return self._generalError
def retrieveContactPerson(self):
try:
if not(self.IndexContactPersonAccount == self.undefined):
tempref = Reference.get(self.IndexContactPersonAccount)
if tempref.readIsValid():
return tempref
else:
return self.undefined
else:
return self._ContactPersonDoNotExist
except:
return self._generalError
# First The contact person class must already exist
# Check to see if the person logged in is the owner of the school record for which the contact person is being
# saved.
#TODO-CREATE AN INTERNAL NOTIFICATION MESSAGING SYSTEM FOR SYSTEM CHANGES SUCH AS BEING MADE A CONTACT PERSON
# FOR A SCHOOL
def saveContactPerson(self):
try:
Guser = users.get_current_user()
if Guser:
ORef = self.retrieveRecordCreator()
if not(ORef == self.undefined) or not(ORef == self._generalError) or not(ORef == self._clsReferenceDonotExist):
if ORef.readIsValid():
if ORef.readReference() == Guser.user_id(): # We succesfully verified record ownership
#Verify that the contact person already exist
if not(self.IndexContactPersonAccount == self.undefined):
CRef = self.retrieveContactPerson()
if not(CRef == self.undefined) or not(CRef == self._ContactPersonDoNotExist) or not(CRef == self._generalError):
# Contact Person already Exist
# Check if self._contactPersonAccount is Valid and the References Match
if self._contactPersonAccount.readIsValid() and (self._contactPersonAccount.readReference() == CRef.readReference()):
CRef.writeVerEmail(self._contactPersonAccount.readVerEmail())
CRef.writeUsername(self._contactPersonAccount.readUsername())
CRef.writeReference(self._contactPersonAccount.readReference())
CRef.writePassword(self._contactPersonAccount.readPassword())
CRef.writeDateTimeVerified(self._contactPersonAccount.readDatetimeVerified())
CRef.writeIDNumber(self._contactPersonAccount.readIDNumber())
CRef.writeIsUserVerified(self._contactPersonAccount.readIsUserVerified())
CRef.writeLogoPhoto(self._contactPersonAccount.readLogoPhoto())
if CRef.readIsValid():
self.IndexContactPersonAccount = CRef.put()
return self.IndexContactPersonAccount
else:
return self._SchoolContactPersonInvalid
else:
return self._ContactPersonDoNotExist
else:
return self._ContactPersonDoNotExist
else:
return self._ContactPersonDoNotExist
else:
return self._UserNotAuthorised
else:
return self._AccountDetailsInvalid
else:
return self._SchoolContactPersonDoNotExist
else:
return self._userNotLoggedin
except:
return self._generalError
class Tertiary (db.Expando):
strInstitutionName = db.StringProperty()
clsPhysicalAddress = PhysicalAddress()
clsContactDetails = ContactDetails()
clsContactPerson = Names()
isValid = db.BooleanProperty(default=False)
isVerified = db.BooleanProperty(default=False) #Verification of the School Existence, can also be conducted through Social Networks
DateCreated = db.DateTimeProperty(auto_now_add=True)
DateModified = db.DateTimeProperty(auto_now=True)
def readInstitutionName(self):
pass
def writeInstitutionName(self):
pass
def readPhysicalAddress(self):
pass
def writePhysicalAddress(self):
pass
def readContactDetails(self):
pass
def writeContactDetails(self):
pass
def readContactPerson(self):
pass
def writeContactPerson(self):
pass
def readIsValid(self):
pass
def setIsValid(self):
pass
def readIsVerified(self):
pass
def setIsVerified(self):
pass
class SubjectandMarks (MyConstants,ErrorCodes):
_maxSubjectLen = 256
_minSubjectLen = 1
_maxSubjectMark = 100
_minSubjectMark = 0
_maxSubjectLevel = 12
_minSubjectLevel = 0
_maxSubjectCodeLen = 8
_minSubjectCodeLen = 0
_maxSubjectGrade = 12
_minSubjectGrade = 0
_maxNameofInstitutionLen = 256
_minNameofInstitutionLen = 1
strSubject = db.StringProperty()
strTotalMark = db.StringProperty()
strTotalLevel = db.StringProperty()
strSubjectCode = db.StringProperty()
strSubjectGrade = db.StringProperty()
def readSubject (self):
try:
temp = str(self.strSubject)
temp = temp.strip()
temp = temp.title()
except:
return self._generalError
def writeSubject (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
strinput = strinput.title()
if ((strinput.isalnum()) and (len(strinput) <= self._maxSubjectLen) and (len(strinput) >= self._minSubjectLen)):
self.strSubject = strinput
return True
else:
self.strSubject = self.undefined
return False
except:
return self._generalError
def readTotalMark (self):
try:
temp = str(self.strTotalMark)
temp = temp.strip()
if ((temp.isdigit()) and (int(temp) <= self._maxSubjectMark) and (int(temp) >= self._minSubjectMark)):
self.strTotalMark = temp
return temp
else:
return self.undefined
except:
return self._generalError
def writeTotalMark (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
if ((strinput.isdigit()) and (int(strinput) <= self._maxSubjectMark) and (int(strinput) >= self._minSubjectMark)):
self.strTotalMark = strinput
return True
else:
return False
except:
return self._generalError
def readTotalLevel (self):
try:
temp = str(self.strTotalLevel)
temp = temp.strip()
if ((temp.isdigit()) and (int(temp) <= self._maxSubjectLevel) and (int(temp) >= self._minSubjectLevel)):
return temp
else:
return self.undefined
except:
return self._generalError
def writeTotalLevel (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
if ((strinput.isdigit()) and (int(strinput) <= self._maxSubjectLevel) and (int(strinput) >= self._minSubjectLevel)):
self.strTotalLevel = strinput
return True
else:
return False
except:
return self._generalError
def readSubjectCode (self):
try:
temp = str(self.strSubjectCode)
temp = temp.strip()
if ((temp.isalnum()) and (len(temp) == self._maxSubjectCodeLen)):
return temp
else:
return self.undefined
except:
return self._generalError
def writeSubjectCode (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
if ((strinput.isalnum()) and (len(strinput) == self._maxSubjectCodeLen)):
self.strSubjectCode = strinput
return True
else:
return False
except:
return self._generalError
def readSubjectGrade (self):
try:
temp = str(self.strSubjectGrade)
temp = temp.strip()
if ((temp.isdigit()) and (int(temp) <= self._maxSubjectGrade) and (int(temp) >= self._minSubjectGrade)):
return temp
else:
return self.undefined
except:
return self._generalError
def writeSubjectGrade (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
if ((strinput.isdigit()) and (int(strinput) <= self._maxSubjectGrade) and (int(strinput) >= self._minSubjectGrade)):
self.strSubjectGrade = strinput
return True
else:
return False
except:
return self._generalError
#this class defines the list of subjects
class lstSubjectsMarks (SubjectandMarks):
# the original value on the list is undefined and a real value will be stored on the first run
lstSubjectsAndMarks = db.ListProperty(item_type=str) #Stores all the subjects and their marks in a list of subjects
#read a certain value on the subjects marks list
# if this is the first read it will return undefined
#teh read functions read values on ram and also write values on ram without worrying about where the values will be
# stored as this decision will influence the platform such as Google App Engine or any other platform
# for Google App Engine then the storage functions will be written on a separate module and for any other platform
def readSubjectsMarks (self, strindex):
try:
strindex = str(strindex)
strindex = strindex.strip()
if ((strindex.isdigit()) and (int(strindex) <= (len(self.lstSubjectsAndMarks) - 1)) and (int(strindex) >= 0)):
# we have determined that the passed value is digit and within bounds of the list
# then we can return that value
return self.lstSubjectsAndMarks[int(strindex)]
else:
return self.undefined
except:
return self.undefined
#write the subjects marks on a certain index
def writeSubjectsMarks (self, clsinput, strindex):
try:
strindex = str(strindex)
strindex = strindex.strip()
if ((strindex.isdigit()) and (int(strindex) <= (len(self.lstSubjectsAndMarks) - 1)) and (int(strindex) >= 0)):
#now that we know the index is valid we can continue to write the SubjectMarks Class
if (clsinput.readSubject() <> self.undefined): #testing to see if the data is valid
intStrindex = int(strindex)
self.lstSubjectsAndMarks.append(clsinput, intStrindex)
return True
else:
return False
else: #something is wrong with the index
return False
except:
return False
# Adding new subjects and marks at the end of the list
def addSubjectsMarks (self, clsinput):
try:
#if this is the first time the following test will evaluate to true meaning the undefined field will be removed.
if (self.lstSubjectsAndMarks[0] == self.undefined):
self.lstSubjectsAndMarks.remove(self.undefined)
if not(clsinput.readSubject() == self.undefined):
self.lstSubjectsAndMarks.append(clsinput)
self.lstSubjectsAndMarks.sort()
return True
else:
return False
except:
return False
def removeSubjectsMarks (self, clsinput):
try:
self.lstSubjectsAndMarks.remove(clsinput)
self.lstSubjectsAndMarks.sort()
return True
except:
return False
# Searching the subjects and marks list using subject name if found return the rest of the subject
def searchSubjectsMarksBySubjectName (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
strinput = strinput.lower()
if (len(self.lstSubjectsAndMarks) > 0):
i = 0
while (i < (len(self.lstSubjectsAndMarks))):
temp = self.lstSubjectsAndMarks[i]
if (strinput == temp.readSubject()):
return temp
else:
i = i + 1
else:
return self.undefined
except:
return self.undefined
def searchSubjectsMarksbySubjectCode (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
strinput = strinput.lower()
if (len(self.lstSubjectsAndMarks) > 0):
i = 0
while (i < (len(self.lstSubjectsAndMarks))):
temp = self.lstSubjectsAndMarks[i]
if (strinput == temp.readSubjectCode()):
return temp
else:
i = i + 1
else:
return self.undefined
except:
return self.undefined
#Searches the subject marks list and return all the subjects on a specific grade and its more likely to return all
#the subjects in the list as they could belong to the same person. and might be listed as subjects for highest grade
# passed. so this function will return a list
def searchSubjectsMarksBySubjectGrade (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
strinput = strinput.lower()
if (len(self.lstSubjectsAndMarks) > 0 ):
i = 0
j = 0
templist = lstSubjectsMarks()
while (i < (len(self.lstSubjectsAndMarks))):
temp = self.lstSubjectsAndMarks[i]
if (strinput == temp.readSubjectGrade()):
templist[j] = temp
j = j + 1
i = i + 1
else:
i = i + 1
return templist
else:
return self.undefined
except:
return self.undefined
def searchSubjectsMarksByTotalMark (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
strinput = strinput.lower()
if (len(self.lstSubjectsAndMarks) > 0):
i = 0
j = 0
templist = lstSubjectsMarks()
while (i < (len(self.lstSubjectsAndMarks))):
temp = self.lstSubjectsAndMarks[i]
if (strinput == temp.readTotalMark()):
templist[j] = temp
j = j + 1
i = i + 1
else:
i = i + 1
return templist
else:
return self.undefined
except:
return self.undefined
def searchSubjectsMarksbyTotalLevel (self, strinput):
try:
strinput = str(strinput)
strinput = strinput.strip()
strinput = strinput.lower()
if (len(self.lstSubjectsAndMarks) > 0):
i = 0
j = 0
templist = lstSubjectsMarks()
while (i < (len(self.lstSubjectsAndMarks))):
temp = self.lstSubjectsAndMarks[i]
if (strinput == temp.readTotalLevel()):
templist[j] = temp
j = j + 1
i = i + 1
else:
i = i + 1
return templist
else:
return self.undefined
except:
return self.undefined
####################################################################################################################
####################################################################################################################
####################################################################################################################