Skip to content

First try at adding the omit grade option. - #143

Open
ymoskovits wants to merge 21 commits into
Grade-Notifier:masterfrom
ymoskovits:master
Open

First try at adding the omit grade option.#143
ymoskovits wants to merge 21 commits into
Grade-Notifier:masterfrom
ymoskovits:master

Conversation

@ymoskovits

Copy link
Copy Markdown
Collaborator

Changed the code in a way that I think should add the omit grade option and its functionality. Not sure what is the best way to test it locally tho. Let me know what you guys think.

Comment thread src/core/initializegn.py Outdated
prod = False if not args.prod else True

omitgrade = input(
"Enter omitgrade (True or False): ") if not args.omitgrade else args.omitgrade

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (90 > 79 characters)

Comment thread src/core/initializegn.py Outdated
account_pass = os.getenv('ACCOUNT_PASSWORD')

def run(username, password, school, phone):
def run(username, password, school, phone, omitgrade):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines, found 1

Comment thread src/helper/userdata.py Outdated
return self._number No newline at end of file
return self._number

def get_omitgrade(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line at end of file

Comment thread src/helper/userdata.py Outdated
self._school_code = school_code

def set_omitgrade(sef, omitgrade):
self._omitgrade = omitgrade

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'self'

Comment thread src/helper/userdata.py Outdated
self._password = password
self._number = number
self._school_code = school_code
self._omitgrade = omitgrade;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statement ends with a semicolon

Comment thread src/helper/userdata.py Outdated

class User():
def __init__(self, username, password, number, school_code = None):
def __init__(self, username, password, number, school_code = None, omitgrade = False):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (90 > 79 characters)
unexpected spaces around keyword / parameter equals

Comment thread src/core/grade_notifier.py Outdated
if add_new_user_instance(username):
api = CUNYFirstAPI(username, password)
user = User(username, password, number, args.school.upper())
user = User(username, password, number, args.school.upper(), omitgrade)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (83 > 79 characters)

Comment thread src/core/grade_notifier.py Outdated
number = input(
"Enter phone number: ") if not args.phone else args.phone
omitgrade = input(
"Enter omitgrade (True or False): ") if not args.omitgrade else args.omitgrade

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (90 > 79 characters)

Comment thread src/core/grade_notifier.py Outdated
gpa.get_term_gpa())) .newline() .add(
"Your cumulative GPA is: {0}".format(
gpa.get_cumulative_gpa())) .newline()
if omitgrade == "False" || omitgrade != "True":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SyntaxError: invalid syntax
missing whitespace around operator

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python has the word "or" not ||

Comment thread src/core/grade_notifier.py Outdated
Changelog: The list of classes which have had grade changes
'''
def create_text_message(change_log):
def create_text_message(change_log, omitgrade):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines, found 0

@CUNY-Bot

CUNY-Bot commented Mar 4, 2019

Copy link
Copy Markdown
Collaborator
1 Error
🚫 Oh No! You failed a unit test
Run Python3 ./src/tests/tests.py to see which test failed
..E/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py:643: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=(‘10.100.2.160’, 49304), raddr=(‘128.228.24.52’, 443)>
outcome.errors.clear()
……….
======================================================================
ERROR: test_is_logged_in (main.TestAPIIntegration)
———————————————————————-
Traceback (most recent call last):
File “./src/tests/tests.py”, line 233, in test_is_logged_in
api.login()
File “/usr/local/lib/python3.7/site-packages/cunyfirstapi/cunyfirstapi.py”, line 59, in login
self._password,
File “/usr/local/lib/python3.7/site-packages/cunyfirstapi/login.py”, line 66, in login
encreply = tree.xpath(‘//*[@name=”enc_post_data”]/@value’)[0]
IndexError: list index out of range


Ran 13 tests in 1.494s

FAILED (errors=1)

1 Warning
⚠️ 253 PEP 8 issues found
1 Message
📖 Thanks for remembering to declare trivial!

Generated by 🚫 Danger

Comment thread src/helper/userdata.py Outdated

class User():
def __init__(self, username, password, number, school_code = None):
def __init__(self, username, password, number, school_code = None, omitgrade = "False"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (92 > 79 characters)
unexpected spaces around keyword / parameter equals

@Huddie Huddie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good i'd say. Makes sense to me.
A few suggestions on naming. + We need omitgrades to be a boolean. String acting as a bool doesn't sound ideal.

Comment thread index.php Outdated

<input class="input input--full-width" type="text" name="phone" placeholder="Phone Number" required>
<br>
<input class="input" type="checkbox" name="omitgrade" value="True" >I only want a notification that my grades are available. The text can omit the actual grade I recieved.</input>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about either

  1. removing the last line and adding a footer that says: "The text will omit the actual grade you receive "
  2. Switching the wording to "The text should omit the actual grade I received"

Comment thread index.php Outdated
<br>
<input class="input" type="checkbox" name="omitgrade" value="True" >I only want a notification that my grades are available. The text can omit the actual grade I recieved.</input>
<br>
<!-- <input class="input" type="checkbox" name="lana" value="value">I also want to tweet my grades to Lana Del Rey.</input> -->

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't wait for this! :D

Comment thread src/core/grade_notifier.py Outdated
gpa.get_term_gpa())) .newline() .add(
"Your cumulative GPA is: {0}".format(
gpa.get_cumulative_gpa())) .newline()
if omitgrade == "False" or omitgrade != "True":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of omitgrade being a string acting as a boolean. Let's make it a boolean outright.

Comment thread src/core/grade_notifier.py Outdated
else None
if changelog is not None:
message = create_text_message(changelog)
message = create_text_message(changelog, user.get_omitgrade())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the method name could be: user.requestedGradeOmission.
Reads better I feel.

Comment thread src/helper/userdata.py Outdated

class User():
def __init__(self, username, password, number, school_code = None):
def __init__(self, username, password, number, school_code = None, omitgrade = False):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, here omitgrade is a boolean

Comment thread src/helper/userdata.py Outdated
def set_school_code(self, school_code):
self._school_code = school_code

def set_omitgrade(self, omitgrade):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method name suggestion: requestedGradeOmission

@Huddie

Huddie commented Mar 4, 2019

Copy link
Copy Markdown
Collaborator

Disregard Danger/CunyBot making a fuss, I still haven't fixed it.

@Huddie

Huddie commented Apr 23, 2019

Copy link
Copy Markdown
Collaborator

@ymoskovits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants