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.output(ProjectSupervisorPaginationSchema)
def list_available_groups(query: dict) -> dict:
mode = query.get('mode')
mode = 0 if query.get('mode') else 1
page = query.get('page')
per_page = query.get('per_page')
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:
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). \
having(available_groups > 0)

View File

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

View File

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

View File

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

View File

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

View File

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