-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from ooemperor/dev
Updating installation scripts, fixing bugs and adding new run scripts for frontend
- Loading branch information
Showing
22 changed files
with
266 additions
and
19 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 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 |
---|---|---|
|
@@ -23,4 +23,4 @@ | |
|
||
from . import admin | ||
from . import user | ||
from . import config | ||
from . import config |
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 |
---|---|---|
|
@@ -20,3 +20,4 @@ | |
Init file for the frontend grader | ||
""" | ||
from .app import admin_frontend | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ | |
""" | ||
init file for the user Frontend | ||
@author: mkaiser | ||
""" | ||
""" | ||
from .app import user_frontend |
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
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,87 @@ | ||
# CodeGrader - https://github.com/ooemperor/CodeGrader | ||
# Copyright © 2023, 2024 Michael Kaiser <[email protected]> | ||
# | ||
# This file is part of CodeGrader. | ||
# | ||
# CodeGrader is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# CodeGrader is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with CodeGrader. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
""" | ||
Script to create an admin user object in the Database for login in the admin frontend | ||
Script will be generated and added to the server path. | ||
@author: mkaiser | ||
""" | ||
|
||
from codeGrader.backend.db import Session, AdminUser | ||
import argparse | ||
import sys | ||
import hashlib | ||
|
||
|
||
def addAdmin(username, first_name, last_name, email, password): | ||
""" | ||
Generate an admin user that will be added to the database for the initial setups | ||
@param username: The username for the new admin | ||
@type username: str | ||
@param first_name: The first name of the new admin | ||
@type first_name: str | ||
@param last_name: The lastname of the new admin | ||
@type last_name: str | ||
@param email: The email of the new admin | ||
@type email: str | ||
@param password: The password of the new admin | ||
@type password: str | ||
@return: Print statement about the user | ||
@rtype: str | ||
""" | ||
sql = Session() # open session | ||
password = password.encode('utf-8') # Convert the password to bytes | ||
hash_object = hashlib.sha256(password) # Choose a hashing algorithm (e.g., SHA-256) | ||
hex_dig = hash_object.hexdigest() | ||
admin_dict = { | ||
"username": username, | ||
"first_name": first_name, | ||
"last_name": last_name, | ||
"email": email, | ||
"password": hex_dig, | ||
"tag": "", | ||
"admin_type": 1 | ||
} | ||
admin_user = AdminUser(**admin_dict) # create the object | ||
sql.create(admin_user) # write token to sql | ||
|
||
print(f"User {username} has been created with password {password}") | ||
|
||
|
||
def main(): | ||
""" | ||
The main method adding an admin to the backend. | ||
@return: | ||
""" | ||
|
||
parser = argparse.ArgumentParser( | ||
description="Add Admin User to the Database" | ||
) | ||
parser.add_argument('-u', '--username') | ||
parser.add_argument('-fn', '--first_name') | ||
parser.add_argument('-ln', '--last_name') | ||
parser.add_argument('-e', '--email') | ||
parser.add_argument('-p', '--password') | ||
|
||
args = parser.parse_args() | ||
|
||
addAdmin(args.username, args.first_name, args.last_name, args.email, args.password) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# CodeGrader - https://github.com/ooemperor/CodeGrader | ||
# Copyright © 2023, 2024 Michael Kaiser <[email protected]> | ||
# | ||
# This file is part of CodeGrader. | ||
# | ||
# CodeGrader is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# CodeGrader is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with CodeGrader. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
""" | ||
Script File for starting the User Frontend | ||
@author: mkaiser | ||
""" | ||
|
||
import sys | ||
from codeGrader.frontend.user import user_frontend | ||
import os | ||
|
||
|
||
def main(): | ||
""" | ||
Starting a new instance of the EvaluationService | ||
@return: | ||
""" | ||
os.chdir("/usr/local/lib/python3.11/dist-packages/codeGrader/frontend/user") | ||
user_frontend() | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
Oops, something went wrong.