add support for specifying number of renwal term in as number

This commit is contained in:
Rio6 2022-10-06 10:04:42 -04:00
parent 779e35a08e
commit 301aaeb548
1 changed files with 16 additions and 2 deletions

View File

@ -181,7 +181,14 @@ class User:
entry.loginShell = login_shell
self.login_shell = login_shell
def add_terms(self, terms: List[str]):
def add_terms(self, terms: List[str] or int):
if type(terms) is int:
if len(self.terms) > 0:
last_term = max(Term(t) for t in self.terms)
else:
last_term = Term.current()-1
terms = [repr(last_term+i) for i in range(1, terms+1)]
for term in terms:
if not is_valid_term(term):
raise Exception('%s is not a valid term' % term)
@ -192,7 +199,14 @@ class User:
self.terms.extend(terms)
self.is_club_rep = False
def add_non_member_terms(self, terms: List[str]):
def add_non_member_terms(self, terms: List[str] or int):
if type(terms) is int:
if len(self.non_member_terms) > 0:
last_term = max(Term(t) for t in self.non_member_terms)
else:
last_term = Term.current()-1
terms = [repr(last_term+i) for i in range(1, terms+1)]
for term in terms:
if not is_valid_term(term):
raise Exception('%s is not a valid term' % term)