bug fix - set proper mode in enrollment

This commit is contained in:
Patryk Drzewiński 2022-06-14 01:34:50 +02:00
parent f642d62ff0
commit 3914d19138
6 changed files with 11 additions and 11 deletions

View File

@ -14,15 +14,15 @@ bp = APIBlueprint("registrations", __name__, url_prefix="/registrations")
@bp.input(ProjectSupervisorQuerySchema, location='query') @bp.input(ProjectSupervisorQuerySchema, location='query')
@bp.output(ProjectSupervisorPaginationSchema) @bp.output(ProjectSupervisorPaginationSchema)
def list_available_groups(query: dict) -> dict: def list_available_groups(query: dict) -> dict:
mode = query.get('mode') mode = 0 if query.get('mode') else 1
page = query.get('page') page = query.get('page')
per_page = query.get('per_page') per_page = query.get('per_page')
available_groups = (ProjectSupervisor.limit_group - ProjectSupervisor.count_groups) available_groups = (ProjectSupervisor.limit_group - ProjectSupervisor.count_groups)
ps_query = db.session.query(ProjectSupervisor, available_groups).join(Group) ps_query = db.session.query(ProjectSupervisor, available_groups).join(Group, isouter=True)
if mode is not None: if mode is not None:
ps_query = ps_query.filter(ProjectSupervisor.mode == mode) ps_query = ps_query.filter(ProjectSupervisor.mode != 1-mode)
ps_query = ps_query.group_by(ProjectSupervisor.id). \ ps_query = ps_query.group_by(ProjectSupervisor.id). \
having(available_groups > 0) having(available_groups > 0)

View File

@ -6,7 +6,7 @@ class ProjectSupervisorSchema(ma.Schema):
first_name = fields.Str() first_name = fields.Str()
last_name = fields.Str() last_name = fields.Str()
email = fields.Str() email = fields.Str()
mode = fields.Boolean() mode = fields.Integer()
available_groups = fields.Integer() available_groups = fields.Integer()

View File

@ -15,7 +15,7 @@ export const getEnrollmentList = (
first_name: string first_name: string
last_name: string last_name: string
email: string email: string
mode: boolean mode: number
}[] }[]
}>('http://127.0.0.1:5000/api/students/registrations/', { }>('http://127.0.0.1:5000/api/students/registrations/', {
params, params,

View File

@ -110,7 +110,7 @@ const AddLeader = () => {
{...register('mode', { {...register('mode', {
required: true, required: true,
})} })}
value="1" value="0"
/> />
<label htmlFor="mode-1">Stacjonarny</label> <label htmlFor="mode-1">Stacjonarny</label>
</div> </div>
@ -122,7 +122,7 @@ const AddLeader = () => {
{...register('mode', { {...register('mode', {
required: true, required: true,
})} })}
value="0" value="1"
/> />
<label htmlFor="mode-0">Niestacjonarny</label> <label htmlFor="mode-0">Niestacjonarny</label>
</div> </div>
@ -134,7 +134,7 @@ const AddLeader = () => {
{...register('mode', { {...register('mode', {
required: true, required: true,
})} })}
value="0" value="2"
/> />
<label htmlFor="mode-2">Oba</label> <label htmlFor="mode-2">Oba</label>
</div> </div>

View File

@ -168,7 +168,7 @@ const Students = () => {
<td>{last_name}</td> <td>{last_name}</td>
<td>{index}</td> <td>{index}</td>
<td>{group === null ? 'Nie' : 'Tak'}</td> <td>{group === null ? 'Nie' : 'Tak'}</td>
<td>{mode ? 'stacjonarny' : 'niestacjonarny'}</td> <td>{mode ? 'Stacjonarny' : 'Niestacjonarny'}</td>
<td> <td>
<button onClick={() => mutateDelete(index)}>X</button> <button onClick={() => mutateDelete(index)}>X</button>
</td> </td>

View File

@ -55,12 +55,12 @@ const Enrollment = () => {
({ available_groups }) => available_groups || !showAvailable, ({ available_groups }) => available_groups || !showAvailable,
) )
.map( .map(
({ first_name, last_name, email, mode, available_groups }) => ( ({ first_name, last_name, email, available_groups }) => (
<tr key={email}> <tr key={email}>
<td>{first_name}</td> <td>{first_name}</td>
<td>{last_name}</td> <td>{last_name}</td>
<td>{email}</td> <td>{email}</td>
<td>{mode ? 'stacjonarny' : 'niestacjonarny'}</td> <td>{mode ? 'Stacjonarny' : 'Niestacjonarny'}</td>
<td>{available_groups}</td> <td>{available_groups}</td>
</tr> </tr>
), ),