New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add manage-scripts to switch system modules value #6532
Conversation
manage.py
Outdated
time.sleep(1) | ||
setattr(Module.query.first(),system,not value) | ||
db.session.commit() | ||
print("Module %s turned %s" %(system,convey[str(not value)])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
missing whitespace around operator
manage.py
Outdated
if system in keys: | ||
value = getattr(Module.query.first(),system) | ||
time.sleep(1) | ||
setattr(Module.query.first(),system,not value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
manage.py
Outdated
print("Module %s turned %s" %(key,convey[str(not value)])) | ||
else: | ||
if system in keys: | ||
value = getattr(Module.query.first(),system) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
manage.py
Outdated
time.sleep(1) | ||
setattr(Module.query.first(),key,not value) | ||
db.session.commit() | ||
print("Module %s turned %s" %(key,convey[str(not value)])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
missing whitespace around operator
manage.py
Outdated
for key in keys: | ||
value = getattr(Module.query.first(),key) | ||
time.sleep(1) | ||
setattr(Module.query.first(),key,not value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
manage.py
Outdated
convey = {'True':'On','False':'Off'} | ||
if system == 'all': | ||
for key in keys: | ||
value = getattr(Module.query.first(),key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
manage.py
Outdated
def switch(system): | ||
import time | ||
keys = [i.name for i in Module.__table__.columns][1:] | ||
convey = {'True':'On','False':'Off'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
missing whitespace after ':'
manage.py
Outdated
@@ -35,6 +36,25 @@ def add_event_identifier(): | |||
event.identifier = get_new_event_identifier() | |||
save_to_db(event) | |||
|
|||
@manager.command |
There was a problem hiding this comment.
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
Codecov Report
@@ Coverage Diff @@
## development #6532 +/- ##
============================================
Coverage 65.11% 65.11%
============================================
Files 295 295
Lines 15284 15284
============================================
Hits 9952 9952
Misses 5332 5332 Continue to review full report at Codecov.
|
README.md
Outdated
|
||
- Before you join development, please set up the system on your local machine and go through the application completely. Press on any link/button you can find and see where it leads to. Explore. (Don't worry ... Nothing will happen to the app or to you due to the exploring :wink: Only thing that will happen is, you'll be more familiar with what is where and might even get some cool ideas on how to improve various aspects of the app.) | ||
- Test the application on your machine and explore the admin area. The test deployment on Heroku will not give you access to the admin section, where you can switch on/off modules, e.g. ticketing and add keys for services, e.g. storage on S3. | ||
- If you would like to work on an issue, drop in a comment at the issue. If it is already assigned to someone, but there is no sign of any work being done, please free to drop in a comment so that the issue can be assigned to you if the previous assignee has dropped it entirely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All changes in README are unrelated to the open issue. Please stick to the changes proposed in the PR. Open another issue of you want to fix other things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change this, must be a result of some rebase/squashing/stashing, fixing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
manage.py
Outdated
@@ -36,6 +37,26 @@ def add_event_identifier(): | |||
save_to_db(event) | |||
|
|||
|
|||
@manager.command | |||
def switch(system): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the option below. Rename to module and pass name and on/off as parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented, please review
manage.py
Outdated
else: | ||
if system in keys: | ||
value = getattr(Module.query.first(),system) | ||
time.sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the system so fast that we deliberately need to make it slow? Or is it needed for some reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize for pushing this as it was making sense with some previous functionality here, similar mistake may not be repeated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
manage.py
Outdated
def module(name,switch): | ||
keys = [i.name for i in Module.__table__.columns][1:] | ||
convey = {"on":True, "off":False} | ||
if switch not in ['on','off']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
manage.py
Outdated
@manager.option('-s', '--switch', dest='switch', default='off') | ||
def module(name,switch): | ||
keys = [i.name for i in Module.__table__.columns][1:] | ||
convey = {"on":True, "off":False} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ':'
manage.py
Outdated
@@ -36,6 +37,27 @@ def add_event_identifier(): | |||
save_to_db(event) | |||
|
|||
|
|||
@manager.option('-n', '--name', dest='name', default='all') | |||
@manager.option('-s', '--switch', dest='switch', default='off') | |||
def module(name,switch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
manage.py
Outdated
print("Module %s turned %s" % (name, switch)) | ||
else: | ||
print("Invalid module selected") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
manage.py
Outdated
db.session.commit() | ||
print("Module %s turned %s" % (key, switch)) | ||
else: | ||
if name in keys: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be changed to elif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, consistent with upstream.
manage.py
Outdated
db.session.commit() | ||
print("Module %s turned %s" % (key, switch)) | ||
elif name in keys: | ||
setattr(Module.query.first(), name, convey[switch]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akshat0047 Fix indentation here (over-indented). Make it four spaces as used in other parts of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
print("Module %s turned %s" % (name, switch)) | ||
else: | ||
print("Invalid module selected") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP 8: expected 2 blank lines, found 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
manage.py
Outdated
elif name == 'all': | ||
for key in keys: | ||
setattr(Module.query.first(), key, convey[switch]) | ||
db.session.commit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move commit to last line instead of commiting in each iteration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented
Fixes #6525 @prateekj117 @iamareebjamal
Short description of what this resolves:
This adds a manage-script which helps the tester to switch any system module On/Off through command line
Changes proposed in this pull request:
Checklist
development
branch.