-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
852 additions
and
1,463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from settings import settings | ||
import random | ||
from router import school | ||
import datetime | ||
from dateutil.relativedelta import relativedelta | ||
from request import build_request | ||
|
||
|
||
class JNVIDGeneration: | ||
def __init__(self, region, school, grade): | ||
self.region = region | ||
self.school = school | ||
self.grade = grade | ||
self.id = ( | ||
self.get_class_code() | ||
+ self.get_jnv_code() | ||
+ self.generate_three_digit_code() | ||
) | ||
|
||
def get_class_code(self): | ||
graduating_year = datetime.date.today() + relativedelta( | ||
years=12 - int(self.grade) | ||
) | ||
return str(graduating_year.year)[-2:] | ||
|
||
def get_jnv_code(self): | ||
return school.get_school( | ||
build_request( | ||
query_params={"region": self.region, "name": self.school_name} | ||
) | ||
) | ||
|
||
def generate_three_digit_code(code=""): | ||
for _ in range(3): | ||
code += random.randint(0, 9) | ||
return code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.