Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Experimental #11

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# TODO
Fill out docker-compose.yml
# Report Microservice Microservice

Fill out GitHub Action workflow
## Explanations
### Routes
/ticket <br>
/ticket/delete/id <br>
/ticket/list <br>
/ticket/id/edit <br>
/ticket/id/answer

Fill out README!
## Documents
[Drafts & Documentation](https://github.com/E-Edu/draft-documents)<br>
[Git Workflow (German)](https://github.com/E-Edu/general/blob/master/guides/conventions.md)<br>
[Code Style (German)](https://github.com/E-Edu/general/blob/master/guides/conventions.md#code-style)


## License

This project is licensed under the `GNU General Public License v3.0`<br>
See `LICENSE` for more information
52 changes: 26 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
version: '3.7'

report_database:
image: mariadb:latest
volumes:
- /var/data/mariadb:/var/lib/mysql # to save the mariadb content
ports:
- 3306:3306 #debug
environment:
- MYSQL_ROOT_PASSWORD=da7tnqw79e5v6nbqw3v5rtwev57mtwm5vrftw75vfnm275v2
- MYSQL_USER=report
- MYSQL_PASSWORD=TuqWuRdjLbSPTRqBnnEU24ZSsqAy9b6LbXA8ZuQg
- MYSQL_DATABASE=report
restart: unless-stopped
container_name: report_database
hostname: report_database
image: mariadb:latest
volumes:
- /var/data/mariadb:/var/lib/mysql # to save the mariadb content
ports:
- 3306:3306 #debug
environment:
- MYSQL_ROOT_PASSWORD=da7tnqw79e5v6nbqw3v5rtwev57mtwm5vrftw75vfnm275v2
- MYSQL_USER=report
- MYSQL_PASSWORD=TuqWuRdjLbSPTRqBnnEU24ZSsqAy9b6LbXA8ZuQg
- MYSQL_DATABASE=report
restart: unless-stopped
container_name: report_database
hostname: report_database

report_microservice:
image: eedu/reportms
ports:
- 5000:5000
environment:
- DATABASE_HOSTNAME=
- DATABASE_PORT=
- DATABASE_USERNAME=
- DATABASE_PASSWORD=
- DATABASE_DATABASE=
- JWT_SECRET=
- SERVICE_SECRET=
restart: unless-stopped
container_name: report_microservice
image: eedu/reportms
ports:
- 80:80
environment:
- DATABASE_HOSTNAME=
- DATABASE_PORT=
- DATABASE_USERNAME=
- DATABASE_PASSWORD=
- DATABASE_DATABASE=
- JWT_SECRET=
- SERVICE_SECRET=
restart: unless-stopped
container_name: report_microservice

9 changes: 5 additions & 4 deletions report/Blueprints/error_handler.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from flask import Blueprint, render_template, abort,request, jsonify
from flask import Blueprint, jsonify

app_error = Blueprint('error-handler', __name__)

app_error = Blueprint('error-handler',__name__)

@app_error.app_errorhandler(404)
def handle_404_error(e):
return jsonify({'error':'Page not found'}),404
return jsonify({'error': 'Page not found'}), 404


@app_error.app_errorhandler(405)
def handle_405_error(e):
return jsonify({'error':'Method not allowed'}),405
return jsonify({'error': 'Method not allowed'}), 405
6 changes: 2 additions & 4 deletions report/Blueprints/routes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import json
import os

import jwt
import os
from flask import Blueprint, request, jsonify

from report import db
Expand All @@ -24,7 +22,7 @@ def ticked_create():
print(e)
return jsonify({'error': 'INVALID_SESSION'}), 400

if userdata.get("status") == 4: # Status 4 == User Banned
if userdata.get("status") == 4: # Status 4 == User Banned
return jsonify({}), 200

user_id = userdata.get("id")
Expand Down
1 change: 0 additions & 1 deletion report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

app = Flask(__name__)


try:
db_path = "mysql+pymysql://" + os.environ.get("DATABASE_USERNAME") + ":" + os.environ.get(
"DATABASE_PASSWORD") + "@" + os.environ.get("DATABASE_HOSTNAME") + ":" + os.environ.get(
Expand Down
3 changes: 1 addition & 2 deletions report/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Ticket(db.Model):
TicketType = db.Column(db.String(10))
role = db.Column(db.String(3))
user_id = db.Column(db.String(1000)) # ! change when >1000 user
isSloved = db.Column(db.Boolean(), default=False)
isSloved = db.Column(db.Boolean(), default=False)

def __init__(self, taskId, title, body, TicketType, user_id):
self.taskId = taskId
Expand All @@ -28,4 +28,3 @@ class Meta:
ticketSchema = TicketSchema()
ticketSchema_many = TicketSchema(many=True)
db.create_all()

3 changes: 2 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import jwt

asd = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256')

jwt.decode(asd, 'secret123', algorithms=['HS256'])
jwt.decode(asd, 'secret123', algorithms=['HS256'])
2 changes: 1 addition & 1 deletion wsgi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from report import app

application = app
application = app