Skip to content

Commit

Permalink
Fix applicant-to-student feature, add possibility to convert to stude…
Browse files Browse the repository at this point in the history
…nt for admin
  • Loading branch information
startsev2000 committed Feb 20, 2024
1 parent 659fcc1 commit e37f0e6
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 24 deletions.
10 changes: 10 additions & 0 deletions back-end/src/ams/serializers/applicants.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ class ApplicantWithApplicationProcessSerializer(serializers.ModelSerializer):
read_only=True,
source="university_info.program.faculty.title",
)
corporate_email = serializers.CharField(
read_only=True,
source="contact_info.corporate_email",
)
personal_phone_number = serializers.CharField(
read_only=True,
source="contact_info.personal_phone_number",
)
application_process = ApplicationProcessSerializer(read_only=True)

class Meta:
Expand All @@ -105,6 +113,8 @@ class Meta:
"fullname",
"birth_date",
"program_code",
"corporate_email",
"personal_phone_number",
"faculty",
"application_process",
]
8 changes: 7 additions & 1 deletion front-end/src/components/@ApplicantsDocuments/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
v-if="field === 'index'"
#body="{ index }"
>
{{ startIndex + index + 1 }}
<div @click="navigateToApplicantToStudent(data[index])">
{{ startIndex + index + 1 }}
</div>
</template>

<template
Expand Down Expand Up @@ -367,6 +369,10 @@ class ApplicantsDocuments extends Vue {
return data[field];
}
navigateToApplicantToStudent(data) {
this.$router.push({ name: "ApplicantToStudent", query: { userId: data.id } });
}
}
export default ApplicantsDocuments;
Expand Down
39 changes: 24 additions & 15 deletions front-end/src/components/ApplicantToStudent/Student.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
Взвод
</div>
<ElFormItem prop="milgroup">
<ElSelect
v-model="student.milgroup"
placeholder="Выберите свой взвод"
style="display: block"
>
<ElSelect v-model="student.milgroup" placeholder="Выберите свой взвод" style="display: block">
<ElOption
v-for="milgroup in milgroups"
:key="milgroup.id"
Expand All @@ -36,11 +32,7 @@
Должность
</div>
<ElFormItem prop="post">
<ElSelect
v-model="student.post"
placeholder="Выберите должность"
style="display: block"
>
<ElSelect v-model="student.post" placeholder="Выберите должность" style="display: block">
<ElOption
v-for="post in studentPosts"
:key="post.value"
Expand Down Expand Up @@ -69,10 +61,18 @@ import { StudentPostsMixin } from "@/mixins/students";
import { validCorEmail } from "@/utils/validate";
import { postError, downloadError } from "@/utils/message";
import { registerStudent } from "@/api/user";
import { findApplicant } from "@/api/applicants";
export default {
mixins: [StudentPostsMixin],
props: {
userId: {
type: [String, Number],
required: true,
},
},
data() {
const requiredRule = {
required: true,
Expand Down Expand Up @@ -113,14 +113,14 @@ export default {
awaitingResponse: false,
student: {
surname: "",
name: "",
patronymic: "",
surname: null,
name: null,
patronymic: null,
milgroup: null,
post: null,
contact_info: {
corporate_email: "",
personal_phone_number: "",
corporate_email: null,
personal_phone_number: null,
},
},
Expand Down Expand Up @@ -167,6 +167,15 @@ export default {
}
this.studentPosts.PRIVATE_STUDENT = { label: "-", value: null };
const response = await findApplicant(this.userId);
const { data } = response;
this.student.name = data.name;
this.student.surname = data.surname;
this.student.patronymic = data.patronymic;
this.student.contact_info.corporate_email = data.contact_info.personal_email;
this.student.contact_info.personal_phone_number = data.contact_info.personal_phone_number;
},
methods: {
Expand Down
8 changes: 8 additions & 0 deletions front-end/src/components/ApplicantToStudent/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<!-- eslint-disable vue/html-quotes -->
<Student
:user-id="userId"
@registration-completed="registrationCompleted"
/>
<!-- eslint-enable vue/html-quotes -->
Expand Down Expand Up @@ -52,6 +53,13 @@ import Student from "@/components/ApplicantToStudent/Student";
export default {
components: { Student },
props: {
userId: {
type: [String, Number],
required: true,
},
},
data() {
return {
registrationComplete: false,
Expand Down
14 changes: 7 additions & 7 deletions front-end/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ export const constantRoutes = [
},

// FIXME(ShishckovA): doesn't work, have to change (i.e. pushing instead of patching), fix and test
// {
// path: "/applicant-to-student/",
// name: "ApplicantToStudent",
// component: () => import("@/views/ApplicantToStudent/index.vue"),
// meta: { title: "Регистрация студента", icon: "journal", permissions: ["applicant.applicant.self"] },
// hidden: true,
// },
{
path: "/applicant-to-student/",
name: "ApplicantToStudent",
component: () => import("@/views/ApplicantToStudent/index.vue"),
meta: { title: "Регистрация студента", icon: "journal", permissions: ["applicant.applicant.self"] },
hidden: true,
},

{
path: "/",
Expand Down
16 changes: 15 additions & 1 deletion front-end/src/views/ApplicantToStudent/index.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<template>
<div class="app-container">
<Register />
<Register v-if="userId !== null" :user-id="userId" />
</div>
</template>

<script>
import Register from "@/components/ApplicantToStudent/index";
import { UserModule } from "@/store";
export default {
components: { Register },
data() {
return {
userId: null,
};
},
mounted() {
const { userId } = this.$route.query;
if (userId === undefined) {
this.userId = UserModule.personId;
} else {
this.userId = userId;
}
},
};
</script>
2 changes: 2 additions & 0 deletions front-end/src/views/ApplicantsDocuments/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ export default {
this.data = data.results.map(item => ({
birthday: moment(item.birth_date).format("DD.MM.yyyy"),
faculty: item.faculty,
phone: item.phone,
email: item.email,
fullname: item.fullname,
id: item.id,
passport: item.passport,
Expand Down

0 comments on commit e37f0e6

Please sign in to comment.