Commit 1375b343 authored by Shashank Kumar's avatar Shashank Kumar

Adds Encryption tools UI

Adding Encryption tools UI
Integrating UI with json to populate tools menu
Importing modules from the json data
parent 26413bd3
# Python
*.pyc
# For Tests
.pytest_cache .pytest_cache
.coverage .coverage
# Database File
new_contributor_wizard.db
...@@ -12,11 +12,12 @@ before_script: ...@@ -12,11 +12,12 @@ before_script:
pylint: pylint:
type: test type: test
script: script:
- pipenv run pylint main.py - pipenv run pylint main
- pipenv run pylint settings
- pipenv run pylint modules - pipenv run pylint modules
pytest: pytest:
type: test type: test
script: script:
- pipenv run pytest tests/ - pipenv run pytest tests
- pipenv run pytest --cov=modules - pipenv run pytest --cov=modules
...@@ -9,8 +9,8 @@ pytest = "==3.6.0" ...@@ -9,8 +9,8 @@ pytest = "==3.6.0"
pytest-cov = "==2.5.1" pytest-cov = "==2.5.1"
[packages] [packages]
cython = "==0.23" cython = "==0.28"
kivy = "==1.9.1" "kivy-1.10.1" = {path = "git+http://github.com/kivy/kivy.git"}
[requires] [requires]
python_version = "3.5" python_version = "3.5"
This diff is collapsed.
v0.0.1 v0.0.1
## June 7 2018
- Sign Up feature added.
## June 11 2018
- Adding Dashboard feature
- Adding blog, cli, communication, encryption, how_to_use, vcs and way_ahead modules for courseware
- Adding application, profile and theme modules for settings
## June 11 2018
- Adding Dashboard feature
- Adding blog, cli, communication, encryption, how_to_use, vcs and way_ahead modules for courseware
- Adding application, profile and theme modules for settings
## June 3 2018 ## June 3 2018
......
[
{"application_settings": 1},
{"blog": 1},
{"cli": 1},
{"communication": 1},
{"encryption":[
{
"tutorials": 0
},
{
"tools": [
{
"Create and manage key pair": {
"difficulty": "Beginner"
},
"Encrypt a message": {
"difficulty": "Intermediate"
},
"Decrypt a message": {
"difficulty": "Intermediate"
},
"Sign other keys": {
"difficulty": "Advance"
}
}
]
}
]
},
{"how_to_use": 1},
{"profile_settings": 1},
{"theme_settings": 1},
{"vcs": 1},
{"way_ahead": 1}
]
\ No newline at end of file
...@@ -78,6 +78,8 @@ There are two type of testing being done for this application. ...@@ -78,6 +78,8 @@ There are two type of testing being done for this application.
- `main.py` - It contains the Root Kivy Application which is to run in order to start the GUI. - `main.py` - It contains the Root Kivy Application which is to run in order to start the GUI.
- `settings.py` - This modules sets up the database which is later integrated with the entire application.
- `data` - It contains static application data which can be used by application at anytime. It helps when the machine is offine. - `data` - It contains static application data which can be used by application at anytime. It helps when the machine is offine.
- `docs` - This directory should and only contain the documentations for developers, contributors and end users. - `docs` - This directory should and only contain the documentations for developers, contributors and end users.
...@@ -86,4 +88,54 @@ There are two type of testing being done for this application. ...@@ -86,4 +88,54 @@ There are two type of testing being done for this application.
- `tests` - This directory should and only contain the Test written for the application, both for application logic and GUI. - `tests` - This directory should and only contain the Test written for the application, both for application logic and GUI.
- `ui` - This directory should and only contain the `.kv` files which uses Kivy Language in order to create the widget tree. Hence, making the UI designing easier. - `ui` - This directory should and only contain the `.kv` files which uses Kivy Language in order to create the widget tree.
### Sign Up Module
- `modules/signup/` contains the Python logic for Sign Up. They can be described as below.
- `exceptions.py` contains SignUp module specific custom exception classes
- `services.py` contains service functions for SignUp module
- `signup.py` contains KIVY UI and other integrations for SignUp module
- `validations.py` contains user information validation functions
- `utils.py` contains utility functions to help out with SignUp operations
- `ui/signup.kv` file contains KIVY widget tree which in turn renders the UI for the Sign Up module.
- `tests/signup/` contains written tests for the Sign Up module. They can be described as below.
- `test_services.py` - contains tests for `modules/signup/services.py`
- `test_utils.py` - contains tests for `modules/signup/utils.py`
- `test_validation.py` - contains tests for `modules/signup/validations.py`
### The Dashboard
- `modules/dashboard/` contains modules for Dashboard features. They can be described as below.
- `dashboard.py` contains Dashboard class for integration with courseware modules (blog, cli, communication, encryption, how_to_use, vcs and way_ahead), settings (application, profile and theme), and the UI
- `ui/dashboard.py` contains KIVY widget tree which in turn renders the UI for the Dashboard module.
### The Courseware
- How To Use - This module helps user getting started with New Contributor Wizard application and is placed in `how_to_use/`
- Communication - This module helps user understand importance of communication and the tools involved like IRC and mailing lists and is places in `communication/`
- CLI - This module helps user learn about Command Line Interface and is places in `cli/`
- Blog - This module helps user create and deploy blogs and is placed in `blog/`
- Version Control - This module helps user get started with managing projects using Version Control System like git and is places in `vcs/`
- Encryption - This module helps user understand the importance of encryption with the help of tools used for the same and is places in `encryption/`
- Way Ahead - This module helps user reach out to differnt communities and explore open source projects and events like Google Summer of Code and is placed in `way_ahead`
### The Settings
- The settings for the entire New Contributor Wizard in places in `settings/`. They can be described as below.
- `application.py` module contains application specific settings like language
- `profile.py` module contains user related settings like name, email etc
- `theme.py` module contains application theme related settings like color
...@@ -4,7 +4,9 @@ Root Kivy Application ...@@ -4,7 +4,9 @@ Root Kivy Application
from kivy.app import App from kivy.app import App
from kivy.config import Config from kivy.config import Config
from modules.welcome import WelcomeScreen from settings import initializing_database
from modules.signup.signup import SignUp
from modules.dashboard.dashboard import Dashboard
class NewContributorWizard(App): class NewContributorWizard(App):
...@@ -13,15 +15,18 @@ class NewContributorWizard(App): ...@@ -13,15 +15,18 @@ class NewContributorWizard(App):
''' '''
def build(self): def build(self):
return WelcomeScreen() self.load_kv('./ui/main.kv')
if __name__ == '__main__': if __name__ == '__main__':
''' '''
Setting window width to 720px and height to 480px Setting up things
'''
initializing_database()
'''
Fixing touch issue with some platforms
''' '''
Config.set('graphics', 'width', '720') Config.set('input', 'mouse', 'mouse')
Config.set('graphics', 'height', '480')
''' '''
Running Kivy application and building root Widget Running Kivy application and building root Widget
......
'''
Modules containing Blog classes
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/blog.kv')
class Blog(BoxLayout):
'''
Blog class for tutorials and tools
'''
pass
'''
Modules containing CLI classes
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/cli.kv')
class CLI(BoxLayout):
'''
Command Line Interface class for tutorials and tools
'''
pass
'''
Modules containing Communication classes
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/communication.kv')
class Communication(BoxLayout):
'''
Communication class for tutorials and tools
'''
pass
'''
Sample module just to showcase how pytest should be used
'''
from datetime import datetime as dt
import calendar
class SampleCommunicationModule():
'''
Sample class to showcase testing
'''
@staticmethod
def return_datetime_object(date_time, given_format):
'''
Sample method to change given date time to unix timestamp
'''
given_datetime_object = dt.strptime(date_time, given_format)
return given_datetime_object
@staticmethod
def unix_time_of_communication(date_time, given_format):
'''
Sample method to change given date time to unix timestamp
'''
given_date_time = dt.strptime(date_time, given_format)
unix_time = calendar.timegm(given_date_time.utctimetuple())
return unix_time
'''
Dashboard module includes classes to showcase Dashboard with different courseware and settings
'''
from copy import copy as cp
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from modules.blog.blog import Blog
from modules.cli.cli import CLI
from modules.communication.communication import Communication
from modules.encryption.encryption import Encryption
from modules.how_to_use.how_to_use import HowToUse
from modules.vcs.vcs import VCS
from modules.way_ahead.way_ahead import WayAhead
from modules.settings.application import ApplicationSettings
from modules.settings.profile import ProfileSettings
from modules.settings.theme import ThemeSettings
Builder.load_file('./ui/dashboard.kv')
class Dashboard(BoxLayout, Screen):
'''
Dashboard class to integrate courseware and settings
'''
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.all_menu_screens = {
'application_settings': ApplicationSettings(),
'blog': Blog(),
'cli': CLI(),
'communication': Communication(),
'encryption': Encryption(),
'how_to_use': HowToUse(),
'profile_settings': ProfileSettings(),
'theme_settings': ThemeSettings(),
'vcs': VCS(),
'way_ahead': WayAhead(),
}
self.all_menu_items = list(self.all_menu_screens.keys())
self.enable_menu('cli')
def enable_menu(self, menu_item_to_enable):
'''
enable_menu function focuses on concerned menu items or settings which is clicked and
removes focus from all other menu items and settings
'''
menu_item_to_enable_widget = self.ids[menu_item_to_enable+'_box']
menu_item_to_enable_color = menu_item_to_enable_widget.canvas.before.children[0].rgba
if menu_item_to_enable_color != [1, 1, 1, 1] or 'settings' in menu_item_to_enable:
self.ids['module_screen'].add_widget(self.all_menu_screens[menu_item_to_enable])
if 'settings' not in menu_item_to_enable:
self.ids[menu_item_to_enable+'_box'].canvas.before.children[0].rgba = [1, 1, 1, 1]
self.ids[menu_item_to_enable+'_label'].color = (0, 0, 0, 1)
all_menu_items_copy = cp(self.all_menu_items)
all_menu_items_copy.remove(menu_item_to_enable)
for menu_item in all_menu_items_copy:
if 'settings' not in menu_item:
self.ids[menu_item+'_box'].canvas.before.children[0].rgba = [0, 0, 0, 1]
self.ids[menu_item+'_label'].color = (1, 1, 1, 1)
self.ids['module_screen'].remove_widget(self.all_menu_screens[menu_item])
'''
Modules containing Encryption classes
'''
from copy import copy as cp
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from modules.encryption.tutorials import tutorials
from modules.encryption.tools import tools
Builder.load_file('./ui/encryption/encryption.kv')
class Encryption(BoxLayout):
'''
Encryption class for tutorials and tools
'''
def __init__(self, **kwargs):
super(Encryption, self).__init__(**kwargs)
self.all_options = {
'tutorials': tutorials.Tutorials(),
'tools': tools.Tools(),
}
self.all_options_items = list(self.all_options.keys())
self.enable_option('tools')
def enable_option(self, option_to_enable):
'''
enable_menu function focuses on concerned menu items or settings which is clicked and
removes focus from all other menu items and settings
'''
option_to_enable_widget = self.ids[option_to_enable+'_box']
option_to_enable_color = option_to_enable_widget.canvas.before.children[0].rgba
if option_to_enable_color != [1, 1, 1, 1]:
self.ids[option_to_enable+'_box'].canvas.before.children[0].rgba = [1, 1, 1, 1]
self.ids[option_to_enable].color = (0, 0, 0, 1)
all_options_items_copy = cp(self.all_options_items)
all_options_items_copy.remove(option_to_enable)
for option in all_options_items_copy:
self.ids[option+'_box'].canvas.before.children[0].rgba = [0, 0, 0, 1]
self.ids[option].color = (1, 1, 1, 1)
self.ids['encryption_content_box'].remove_widget(self.all_options[option])
self.ids['encryption_content_box'].add_widget(self.all_options[option_to_enable])
'''
This modules helps create and manage key pairs
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/encryption/all_tools/create_and_manage_key_pair.kv')
class CreateAndManageKeyPair(BoxLayout):
'''
CreateAndManageKeyPair helps integrate UI with helper functions
'''
pass
'''
This modules helps decrypt a message using private key
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/encryption/all_tools/decrypt_a_message.kv')
class DecryptAMessage(BoxLayout):
'''
DecryptAMessage integrated UI with helper functions
'''
pass
'''
This module helps encrypt a message using public key
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/encryption/all_tools/encrypt_a_message.kv')
class EncryptAMessage(BoxLayout):
'''
DEncryptAMessage integrated UI with helper functions
'''
pass
'''
This module helps user sign other keys with existing key pair
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/encryption/all_tools/sign_other_keys.kv')
class SignOtherKeys(BoxLayout):
'''
SignOtherKeys integrated UI with helper functions
'''
pass
'''
Modules containing Tools classes for Encryption
'''
import json
from importlib import import_module
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/encryption/tools.kv')
class ToolBox(BoxLayout):
'''
ToolBox class to present available tools
'''
pass
class BackToToolsMenu(BoxLayout):
'''
BackToToolsMenu class presents back button and tool title
'''
pass
class Tools(BoxLayout):
'''
Tools class to present Tools menu of Encryption
'''
def __init__(self, **kwargs):
super(Tools, self).__init__(**kwargs)
self.all_tools = {}
self.removed_tools_menu = None
with open('data/root.json') as data:
json_data = json.loads(data.read())
self.encryption_data = json_data[4]["encryption"]
for key, value in self.encryption_data[1]["tools"][0].items():
value['title'] = key
tool_key = '_'.join(key.lower().split())
self.all_tools[tool_key] = value
self.populate_tools_menu()
def populate_tools_menu(self):
'''
populate_tools_menu gathers the information about the tools and populates it on the tools
menu in GUI
'''
difficulty_palette = {
'Beginner': (0.015, 0.588, 1, 1),
'Intermediate': (0.2, 0.792, 0.498, 1),
'Advance': (0.890, 0.090, 0.039, 1),
}
count_widgets = 0
for key, value in self.all_tools.items():
tool_title = value['title']
tool_difficulty = value["difficulty"]
tool_color = difficulty_palette[tool_difficulty]
tool_box_widget = ToolBox()
tool_box_widget.ids['tool_button'].bind(on_press=self.open_tool)
tool_box_widget.id = key
tool_box_widget.canvas.before.children[0].rgba = tool_color
tool_box_widget.ids['tool_box_title'].text = tool_title
tool_box_widget.ids['tool_box_difficulty'].text = tool_difficulty
self.ids['tools_menu'].add_widget(tool_box_widget)
self.import_tool_modules(key)
def import_tool_modules(self, tool_to_import):
'''
import_tool_modules try to import tool_to_import named module and also the class
ToolToImport
'''
module_name = tool_to_import
class_name = ''.join(tool_to_import.title().split('_'))
tool_module = import_module('modules.encryption.tools.all_tools.'+module_name)
tool_class = getattr(tool_module, class_name)
self.all_tools[tool_to_import]['module'] = tool_module
self.all_tools[tool_to_import]['class'] = tool_class
def open_tool(self, button_object):
'''
open_tool creates a new widget with option to get back to the tools menu and also
imports the selected tool module as the children widget
'''
tool_id = button_object.parent.parent.id
self.removed_tools_menu = self.children[0]
self.remove_widget(self.children[0])
box_layout = BoxLayout()
box_layout.id = 'tools_menu'
box_layout.orientation = 'vertical'
back_to_tool_menu = BackToToolsMenu()
back_to_tool_menu.ids['tool_title'].text = self.all_tools[tool_id]['title']
back_to_tool_menu.ids['tools_menu_button'].bind(on_press=self.back_to_tools_menu)
box_layout.add_widget(back_to_tool_menu)
box_layout.add_widget(self.all_tools[tool_id]['class']())
self.add_widget(box_layout)
def back_to_tools_menu(self, button_object):
'''
back_to_tools_menu removed the tool widget and replaces tools menu
'''
self.remove_widget(button_object)
self.remove_widget(self.children[0])
self.add_widget(self.removed_tools_menu)
'''
Modules containing Tutorials classes for Encryption
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/encryption/tutorials.kv')
class Tutorials(BoxLayout):
'''
Tutorials class for Encryption
'''
pass
'''
Modules containing How To Use classes
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/how_to_use.kv')
class HowToUse(BoxLayout):
'''
HowToUser class for introduction on how to user New
Contributor Wizard
'''
pass
'''
Modules containing Application Settings classes
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/application_settings.kv')
class ApplicationSettings(BoxLayout):
'''
ApplicationSettings class for settings related to New
Contributor Wizard application
'''
pass
'''
Modules containing Profile Settings classes
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/profile_settings.kv')
class ProfileSettings(BoxLayout):
'''
ProfileSettings class for settings related to signed in user
'''
pass
'''
Modules containing Theme Settings classes
'''
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_file('./ui/theme_settings.kv')
class ThemeSettings(BoxLayout):
'''
ThemeSettings class for settings related to Theme of application
'''
pass
'''
Exceptions module contains exception classes specific to signup module
'''
class SignUpError(Exception):
'''
SignUpError class can be used to raise exception related to
User's imput
'''
def __init__(self, message):
self.message = message
super().__init__(message)