Skip to content
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

Merged
merged 1 commit into from Oct 18, 2019
Merged

feat: add manage-scripts to switch system modules value #6532

merged 1 commit into from Oct 18, 2019

Conversation

akshat0047
Copy link
Member

@akshat0047 akshat0047 commented Oct 17, 2019

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:

  • Added a manage command with the name switch
  • switch command provides the option to switch a specific module or all of them by specifying module_name or all
  • Updated documentation in readme.md under the 'Testing' heading

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

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)]))

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)

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)

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)]))

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)

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)

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'}

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

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
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

Merging #6532 into development will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d781989...c52c32f. Read the comment docs.

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.
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member Author

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):
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, on it

Copy link
Member Author

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)
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member Author

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']:

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}

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):

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")

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 Show resolved Hide resolved
manage.py Show resolved Hide resolved
manage.py Show resolved Hide resolved
manage.py Outdated
db.session.commit()
print("Module %s turned %s" % (key, switch))
else:
if name in keys:
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Implemented

Copy link
Member Author

Choose a reason for hiding this comment

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

Updating...

Copy link
Member Author

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])
Copy link
Member

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.

Copy link
Member Author

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")

Copy link
Member

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.

Copy link
Member Author

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()
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Implemented

@iamareebjamal iamareebjamal changed the title added manage-scripts to switch system modules value feat: add manage-scripts to switch system modules value Oct 18, 2019
@auto-label auto-label bot added the feature label Oct 18, 2019
@iamareebjamal iamareebjamal merged commit c873481 into fossasia:development Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

default value of ticket_include is false in system
4 participants