bug fix - correction of Leaders panel and create_project_supervisor method

This commit is contained in:
Patryk Drzewiński 2022-06-13 18:41:28 +02:00
parent ddb9133f6c
commit 39339f0ac5
6 changed files with 10 additions and 9 deletions

View File

@ -1,9 +1,11 @@
from flask import Blueprint from flask import Blueprint
from .students import bp as students_bp from .students import bp as students_bp
from .project_supervisor import bp as project_supervisor_bp
from .groups import bp as groups_bp from .groups import bp as groups_bp
bp = Blueprint("coordinator", __name__, url_prefix="/coordinator") bp = Blueprint("coordinator", __name__, url_prefix="/coordinator")
bp.register_blueprint(students_bp) bp.register_blueprint(students_bp)
bp.register_blueprint(project_supervisor_bp)
bp.register_blueprint(groups_bp) bp.register_blueprint(groups_bp)

View File

@ -44,8 +44,7 @@ def create_project_supervisor(data: dict) -> dict:
email = data['email'] email = data['email']
limit_group = data['limit_group'] limit_group = data['limit_group']
mode = data['mode'] mode = data['mode']
project_supervisor = ProjectSupervisor.query.filter_by(first_name=first_name).filter_by(last_name=last_name).first()
project_supervisor = ProjectSupervisor.query.filter(first_name=first_name).filter(last_name=last_name).first()
if project_supervisor is not None: if project_supervisor is not None:
abort(400, "Project Supervisor has already exists!") abort(400, "Project Supervisor has already exists!")

View File

@ -108,8 +108,8 @@ class ProjectSupervisorsPaginationSchema(ma.Schema):
class ProjectSupervisorCreateSchema(ma.Schema): class ProjectSupervisorCreateSchema(ma.Schema):
first_name = fields.Str(validate=validate.Length(min=1, max=255), required=True) first_name = fields.Str(validate=validate.Length(min=1, max=255), required=True)
last_name = fields.Str(validate=validate.Length(min=1, max=255), required=True) last_name = fields.Str(validate=validate.Length(min=1, max=255), required=True)
email = fields.Str(validate=validate.Length(min=0, max=11), required=True) email = fields.Str(validate=validate.Length(min=1, max=255), required=True)
limit_group = fields.Integer(validate=validate_index) limit_group = fields.Integer()
mode = fields.Integer(required=True) mode = fields.Integer(required=True)

View File

@ -27,15 +27,15 @@ export const getLeaders = (
}> = {}, }> = {},
) => ) =>
axiosInstance.get<LeaderResponse>( axiosInstance.get<LeaderResponse>(
'http://127.0.0.1:5000/api/coordinator/project_supervisors', 'http://127.0.0.1:5000/api/coordinator/project_supervisor',
{ params }, { params },
) )
export const createLeader = (payload: Leader) => export const createLeader = (payload: Leader) =>
axiosInstance.post('http://127.0.0.1:5000/api/coordinator/project_supervisors/', payload) axiosInstance.post('http://127.0.0.1:5000/api/coordinator/project_supervisor/', payload)
export const deleteLeader = (payload: Number) => export const deleteLeader = (payload: Number) =>
axiosInstance.delete( axiosInstance.delete(
'http://127.0.0.1:5000/api/coordinator/project_supervisors/'+payload.toString()+'/', 'http://127.0.0.1:5000/api/coordinator/project_supervisor/'+payload.toString()+'/',
) )

View File

@ -25,7 +25,6 @@ const AddLeader = () => {
) )
const onSubmit = (data: Leader) => { const onSubmit = (data: Leader) => {
console.log(data)
mutateCreateLeader(data) mutateCreateLeader(data)
} }
@ -36,7 +35,7 @@ const AddLeader = () => {
> >
{isAlertVisible && ( {isAlertVisible && (
<div className="alert alert-success shadow-lg"> <div className="alert alert-success shadow-lg">
<span>Udało się dodać studenta!</span> <span>Udało się dodać opiekuna!</span>
</div> </div>
)} )}

View File

@ -86,6 +86,7 @@ const Leaders = () => {
<td>{last_name}</td> <td>{last_name}</td>
<td>{email}</td> <td>{email}</td>
<td>{limit_group}</td> <td>{limit_group}</td>
<td>{count_group}</td>
<td>{mode==0 ? "Stacjonarny" : mode==1 ? "Niestacjonarny" : "Nie/stacjonarny"}</td> <td>{mode==0 ? "Stacjonarny" : mode==1 ? "Niestacjonarny" : "Nie/stacjonarny"}</td>
<td><button onClick={() => deleteLeader(id).then(() => refetchLeaders())}>X</button></td> <td><button onClick={() => deleteLeader(id).then(() => refetchLeaders())}>X</button></td>
</tr> </tr>