Compare commits

14 Commits

Author SHA1 Message Date
43b056f412 fix: broken cypress tests due to new internship list view
Some checks failed
Cypress E2E Tests / cypress-tests (push) Has been cancelled
2025-12-04 12:46:10 +01:00
Veronika Fehérvíziová
b9be4a2e6c fix: allow changing internship status when denied by admin 2025-12-02 22:53:01 +01:00
Veronika Fehérvíziová
06e6e59a18 feat: notify company of internship status updates 2025-12-02 22:52:22 +01:00
Veronika Fehérvíziová
a9ac8a2735 refactor: rename contact method to contactPerson to avoid default conflicts 2025-12-02 22:51:53 +01:00
Veronika Fehérvíziová
01aae85efc refactor: update email template for internship status updates 2025-12-02 22:51:29 +01:00
Veronika Fehérvíziová
b95cdb070d Revert "refactor: increase the number of users and companies in seeder"
This reverts commit 1d2016c011.
2025-12-02 20:40:10 +01:00
Veronika Fehérvíziová
e64b6c2eca feat: add dynamic max year of study based on selected program in registration form 2025-12-02 20:32:31 +01:00
Veronika Fehérvíziová
4a5a4f990c feat: improve phone input validation and update study program options in registration form 2025-12-02 20:28:17 +01:00
Veronika Fehérvíziová
2b31c1d2ad feat: enhance phone input validation in registration form 2025-12-02 20:27:59 +01:00
Veronika Fehérvíziová
b612c0f873 feat: add validation rules for internship filter inputs 2025-12-02 20:26:14 +01:00
Veronika Fehérvíziová
9de30a7df1 refactor: improve address generation in Company and Student data factories 2025-12-02 19:30:54 +01:00
Veronika Fehérvíziová
1d2016c011 refactor: increase the number of users and companies in seeder 2025-12-02 19:30:42 +01:00
Veronika Fehérvíziová
687018e0fe rename and translate CLI command for admin create 2025-12-02 19:10:13 +01:00
Veronika Fehérvíziová
6902eadef5 refactor: rename CLI for creating admin 2025-12-02 19:00:04 +01:00
14 changed files with 148 additions and 118 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use Hash;
class CreateAdmin extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:create-admin';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new admin user';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('=== Create Admin ===');
// Načítanie údajov interaktívne
$firstName = $this->ask('First name');
$lastName = $this->ask('Last name');
$email = $this->ask('E-mail');
// Kontrola duplicity emailu
if (User::where('email', $email)->exists()) {
$this->error('A user with the same email already exists.');
return 1;
}
$password = $this->secret('Enter password');
$phone = $this->ask('Enter phone number');
// Vytvorenie používateľa
$user = User::create([
'name' => $firstName . ' ' . $lastName,
'first_name' => $firstName,
'last_name' => $lastName,
'email' => $email,
'password' => Hash::make($password),
'active' => true,
'role' => 'ADMIN',
'phone' => $phone,
]);
$this->info("\n Admin {$user->first_name} {$user->last_name} created.");
return 0;
}
}

View File

@@ -1,59 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
class CreateGarant extends Command
{
/**
* Názov CLI príkazu.
*/
protected $signature = 'user:create-garant';
/**
* Popis príkazu.
*/
protected $description = 'Interaktívne vytvorí nového používateľa s rolou admin (garant)';
/**
* Spustenie príkazu.
* php artisan user:create-garant
*/
public function handle()
{
$this->info('=== Vytvorenie garanta (admin) ===');
// Načítanie údajov interaktívne
$firstName = $this->ask('Zadaj krstné meno');
$lastName = $this->ask('Zadaj priezvisko');
$email = $this->ask('Zadaj email');
// Kontrola duplicity emailu
if (User::where('email', $email)->exists()) {
$this->error('Používateľ s týmto emailom už existuje.');
return 1;
}
$password = $this->secret('Zadaj heslo (nebude sa zobrazovať)');
$phone = $this->ask('Zadaj telefón ');
// Vytvorenie používateľa
$user = User::create([
'name' => $firstName . ' ' . $lastName,
'first_name' => $firstName,
'last_name' => $lastName,
'email' => $email,
'phone' => $phone,
'role' => 'ADMIN',
'password' => Hash::make($password),
]);
$this->info("\n Garant {$user->first_name} {$user->last_name} bol úspešne vytvorený s rolou ADMIN.");
$this->info("Email: {$user->email}");
return 0;
}
}

View File

@@ -123,17 +123,30 @@ class InternshipStatusDataController extends Controller
'modified_by' => $user->id 'modified_by' => $user->id
]); ]);
// mail študentovi
Mail::to($internship->student) Mail::to($internship->student)
->sendNow(new InternshipStatusUpdated( ->sendNow(new InternshipStatusUpdated(
$internship, $internship,
$user->name,
$internship->student->name,
$internship->company->name,
$internshipStatus->status, $internshipStatus->status,
$request->enum('status', InternshipStatus::class), $newStatus->status,
$request->note $request->note,
$user,
recipiantIsStudent: true,
)); ));
// ak zmenu nevykonala firma, posleme mail aj firme
if ($user->id !== $internship->company->contactPerson->id) {
Mail::to($internship->company->contactPerson->email)
->sendNow(new InternshipStatusUpdated(
$internship,
$internshipStatus->status,
$newStatus->status,
$request->note,
$user,
recipiantIsStudent: false,
));
}
$newStatus->save(); $newStatus->save();
return response()->noContent(); return response()->noContent();
} }

View File

@@ -4,6 +4,7 @@ namespace App\Mail;
use App\Enums\InternshipStatus; use App\Enums\InternshipStatus;
use App\Models\Internship; use App\Models\Internship;
use App\Models\User;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Content;
@@ -15,25 +16,23 @@ class InternshipStatusUpdated extends Mailable
use Queueable, SerializesModels; use Queueable, SerializesModels;
private Internship $internship; private Internship $internship;
private string $changedByName;
private string $studentName;
private string $companyName;
private InternshipStatus $oldStatus; private InternshipStatus $oldStatus;
private InternshipStatus $newStatus; private InternshipStatus $newStatus;
private string $note; private string $note;
private User $changedBy;
private bool $recipiantIsStudent;
/** /**
* Create a new message instance. * Create a new message instance.
*/ */
public function __construct(Internship $internship, string $changedByName, string $studentName, string $companyName, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note) public function __construct(Internship $internship, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note, User $changedBy, bool $recipiantIsStudent)
{ {
$this->internship = $internship; $this->internship = $internship;
$this->changedByName = $changedByName;
$this->studentName = $studentName;
$this->companyName = $companyName;
$this->oldStatus = $oldStatus; $this->oldStatus = $oldStatus;
$this->newStatus = $newStatus; $this->newStatus = $newStatus;
$this->note = $note; $this->note = $note;
$this->changedBy = $changedBy;
$this->recipiantIsStudent = $recipiantIsStudent;
} }
/** /**
@@ -55,12 +54,11 @@ class InternshipStatusUpdated extends Mailable
view: 'mail.internship.status_updated', view: 'mail.internship.status_updated',
with: [ with: [
"internship" => $this->internship, "internship" => $this->internship,
"changedByName" => $this->changedByName,
"studentName" => $this->studentName,
"companyName" => $this->companyName,
"oldStatus" => $this->prettyStatus($this->oldStatus->value), "oldStatus" => $this->prettyStatus($this->oldStatus->value),
"newStatus" => $this->prettyStatus($this->newStatus->value), "newStatus" => $this->prettyStatus($this->newStatus->value),
"note" => $this->note, "note" => $this->note,
"recipiantIsStudent" => $this->recipiantIsStudent,
"changedBy" => $this->changedBy,
] ]
); );
} }

View File

@@ -44,7 +44,7 @@ class Company extends Model
/** /**
* Get the contact person (user) for the company. * Get the contact person (user) for the company.
*/ */
public function contact() public function contactPerson()
{ {
return $this->belongsTo(User::class, 'contact'); return $this->belongsTo(User::class, 'contact');
} }

View File

@@ -107,6 +107,10 @@ class Internship extends Model
$current_status === InternshipStatus::CONFIRMED_BY_ADMIN && $userRole === "ADMIN" && !$report_confirmed $current_status === InternshipStatus::CONFIRMED_BY_ADMIN && $userRole === "ADMIN" && !$report_confirmed
=> ['DENIED_BY_ADMIN', 'CONFIRMED_BY_COMPANY', 'DENIED_BY_COMPANY'], => ['DENIED_BY_ADMIN', 'CONFIRMED_BY_COMPANY', 'DENIED_BY_COMPANY'],
// prax bola zamietnutá garantom a ide ju meniť garant
$current_status === InternshipStatus::DENIED_BY_ADMIN && $userRole === "ADMIN"
=> ['CONFIRMED_BY_COMPANY', 'CONFIRMED_BY_ADMIN', 'DENIED_BY_COMPANY'],
// prax bola obhájená a ide ju meniť admin // prax bola obhájená a ide ju meniť admin
$current_status === InternshipStatus::DEFENDED && $userRole === "ADMIN" $current_status === InternshipStatus::DEFENDED && $userRole === "ADMIN"
=> ['NOT_DEFENDED'], => ['NOT_DEFENDED'],

View File

@@ -18,7 +18,7 @@ class CompanyFactory extends Factory
{ {
return [ return [
'name' => fake()->company(), 'name' => fake()->company(),
'address' => fake()->address(), 'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
'ico' => fake()->numberBetween(111111, 999999), 'ico' => fake()->numberBetween(111111, 999999),
'contact' => 0, 'contact' => 0,
'hiring' => fake()->boolean(), 'hiring' => fake()->boolean(),

View File

@@ -18,7 +18,7 @@ class StudentDataFactory extends Factory
{ {
return [ return [
'user_id' => 0, 'user_id' => 0,
'address' => fake()->address(), 'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
'personal_email' => fake()->safeEmail(), 'personal_email' => fake()->safeEmail(),
'study_field' => fake()->randomElement(["AI22m", "AI22b"]), 'study_field' => fake()->randomElement(["AI22m", "AI22b"]),
]; ];

View File

@@ -1,14 +1,21 @@
@include("parts.header") @include("parts.header")
<p>Vážená/ý {{ $studentName }},</p>
<p>stav vašej praxe vo firme {{ $companyName }} bola aktualizovaná zo stavu "{{ $oldStatus }}" na
"{{ $newStatus }}".</p>
<p>Zmenu vykonal <em>{{ $changedByName }}</em>.</p>
<br />
@if($recipiantIsStudent)
<p>Vážená/ý {{ $internship->student->name }},</p>
@else
<p>Vážená/ý {{ $internship->company->contactPerson->name }},</p>
@endif
<p>oznamujeme Vás o zmene praxe:</p>
@if(!$recipiantIsStudent)
<p>Študent: <em>{{ $internship->student->name }} ({{ $internship->student->email }},
{{ $internship->student->phone }})</em></p>
@endif
<p>Stav: <em>{{ $oldStatus }}</em> <strong>-></strong> <em>{{ $newStatus }}</em></p>
<p>Poznámka: <em>{{ $note }}</em>.</p> <p>Poznámka: <em>{{ $note }}</em>.</p>
<p>Zmenu vykonal <em>{{ $changedBy->name }}</em>.</p>
<br /> <br />
<p>s pozdravom</p> <p>S pozdravom.</p>
<p>Systém ISOP UKF</p> <p>Systém ISOP UKF</p>
@include("parts.footer") @include("parts.footer")

View File

@@ -25,6 +25,11 @@ const totalItems = ref(0);
const deleteConfirmDialog = ref(false); const deleteConfirmDialog = ref(false);
const internshipToDelete = ref<Internship | null>(null); const internshipToDelete = ref<Internship | null>(null);
const rules = {
minFilterLen: (v: string) => (v.length >= 3) || 'Min. 3 znaky',
minYear: (v: number | null) => (v === null ? true : v >= 1000) || 'Min. 4-ciferné číslo'
};
const allHeaders = [ const allHeaders = [
{ title: "Študent", key: "student.name", sortable: false }, { title: "Študent", key: "student.name", sortable: false },
{ title: "Firma", key: "company.name", sortable: false }, { title: "Firma", key: "company.name", sortable: false },
@@ -99,16 +104,20 @@ async function confirmDeletion(confirm: boolean) {
<v-row> <v-row>
<v-col cols="12" md="3"> <v-col cols="12" md="3">
<v-text-field v-model="filters.year" label="Rok" type="number" clearable density="compact" /> <v-text-field v-model="filters.year" label="Rok" type="number" clearable density="compact"
:rules="[rules.minYear]" />
</v-col> </v-col>
<v-col cols="12" md="3" v-if="mode !== 'company'"> <v-col cols="12" md="3" v-if="mode !== 'company'">
<v-text-field v-model="filters.company" label="Názov firmy" clearable density="compact" /> <v-text-field v-model="filters.company" label="Názov firmy" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col> </v-col>
<v-col cols="12" md="3" v-if="mode !== 'student'"> <v-col cols="12" md="3" v-if="mode !== 'student'">
<v-text-field v-model="filters.study_programe" label="Študijný program" clearable density="compact" /> <v-text-field v-model="filters.study_programe" label="Študijný program" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col> </v-col>
<v-col cols="12" md="3" v-if="mode !== 'student'"> <v-col cols="12" md="3" v-if="mode !== 'student'">
<v-text-field v-model="filters.student" label="Študent" clearable density="compact" /> <v-text-field v-model="filters.student" label="Študent" clearable density="compact"
:rules="[rules.minFilterLen]" />
</v-col> </v-col>
</v-row> </v-row>
@@ -127,13 +136,13 @@ async function confirmDeletion(confirm: boolean) {
<v-tooltip text="Editovať"> <v-tooltip text="Editovať">
<template #activator="{ props }"> <template #activator="{ props }">
<v-btn icon="mdi-pencil" size="small" variant="text" <v-btn icon="mdi-pencil" size="small" variant="text"
:to="`/dashboard/${mode}/internships/edit/${item.id}`" /> :to="`/dashboard/${mode}/internships/edit/${item.id}`" class="internship-edit-btn" />
</template> </template>
</v-tooltip> </v-tooltip>
<v-tooltip text="Vymazať" v-if="mode === 'admin'"> <v-tooltip text="Vymazať" v-if="mode === 'admin'">
<template #activator="{ props }"> <template #activator="{ props }">
<v-btn icon="mdi-delete" size="small" variant="text" color="error" <v-btn icon="mdi-delete" size="small" variant="text" color="error"
@click="() => openDeleteDialog(item)" /> @click="() => openDeleteDialog(item)" class="internship-delete-btn" />
</template> </template>
</v-tooltip> </v-tooltip>
</template> </template>

View File

@@ -19,7 +19,8 @@ useSeoMeta({
const rules = { const rules = {
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole', required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
email: (v: string) => /.+@.+\..+/.test(v) || 'Zadajte platný email', email: (v: string) => /.+@.+\..+/.test(v) || 'Zadajte platný email',
phone: (v: string) => (!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo', phone: (v: string) =>
(!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť', mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
}; };
@@ -101,8 +102,8 @@ async function handleRegistration() {
density="comfortable" /> density="comfortable" />
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:" <v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
variant="outlined" density="comfortable" /> variant="outlined" density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón:" variant="outlined" <v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón (s predvoľbou):"
density="comfortable" /> variant="outlined" density="comfortable" />
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]" <v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" /> label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />

View File

@@ -23,11 +23,14 @@ const rules = {
personal_email: (v: string) => personal_email: (v: string) =>
/.+@.+\..+/.test(v) || 'Zadajte platný osobný email', /.+@.+\..+/.test(v) || 'Zadajte platný osobný email',
phone: (v: string) => phone: (v: string) =>
(!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo', (!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť', mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
}; };
const programs = [ const programs = [
'Aplikovaná informatika', { title: 'Aplikovaná informatika, Bc. (AI22b)', value: 'AI22b' },
{ title: 'Aplikovaná informatika, Bc. (AI15b)', value: 'AI15b' },
{ title: 'Aplikovaná informatika, Mgr. (AI22m)', value: 'AI22m' },
{ title: 'Aplikovaná informatika, Mgr. (AI15m)', value: 'AI15m' },
]; ];
const isValid = ref(false); const isValid = ref(false);
@@ -38,10 +41,11 @@ const form = ref({
studentEmail: '', studentEmail: '',
personalEmail: '', personalEmail: '',
phone: '', phone: '',
studyProgram: programs[0] as string, studyProgram: programs[0]!.value,
year_of_study: 1, year_of_study: 1,
consent: false, consent: false,
}); });
const maxYearOfStudy = ref(0);
const loading = ref(false); const loading = ref(false);
const error = ref(null as null | string); const error = ref(null as null | string);
@@ -80,6 +84,10 @@ async function handleRegistration() {
loading.value = false; loading.value = false;
} }
} }
watch(form, (newForm) => {
maxYearOfStudy.value = newForm.studyProgram.slice(-1) === 'b' ? 3 : 2;
}, { deep: true, immediate: true });
</script> </script>
<template> <template>
@@ -109,14 +117,14 @@ async function handleRegistration() {
<v-text-field v-model="form.personalEmail" :rules="[rules.required, rules.personal_email]" <v-text-field v-model="form.personalEmail" :rules="[rules.required, rules.personal_email]"
label="Alternatívny email:" variant="outlined" density="comfortable" /> label="Alternatívny email:" variant="outlined" density="comfortable" />
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]" label="Telefón:" <v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]"
variant="outlined" density="comfortable" /> label="Telefón (s predvoľbou):" variant="outlined" density="comfortable" />
<v-select v-model="form.studyProgram" :items="programs" :rules="[rules.required]" <v-select v-model="form.studyProgram" :items="programs" :rules="[rules.required]"
label="Študijný odbor:" variant="outlined" density="comfortable" /> label="Študijný odbor:" variant="outlined" density="comfortable" />
<v-number-input control-variant="split" v-model="form.year_of_study" :rules="[rules.required]" <v-number-input control-variant="split" v-model="form.year_of_study" :rules="[rules.required]"
label="Ročník:" :min="1" :max="5"></v-number-input> label="Ročník:" :min="1" :max="maxYearOfStudy"></v-number-input>
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]" <v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" /> label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />

View File

@@ -12,6 +12,7 @@ describe('Admin Student Document Downloads', () => {
cy.contains("Praxe").click() cy.contains("Praxe").click()
cy.url().should('include', '/dashboard/admin/internships') cy.url().should('include', '/dashboard/admin/internships')
cy.wait(2000)
}) })
it('should be able to generate and download the default proof', () => { it('should be able to generate and download the default proof', () => {
@@ -24,13 +25,12 @@ describe('Admin Student Document Downloads', () => {
}) })
cy.get('@randomRow').within(() => { cy.get('@randomRow').within(() => {
cy.get('td').contains('Editovať').click() cy.get('td').get('.internship-edit-btn').click()
}) })
}) })
cy.url().should('include', '/dashboard/admin/internships/edit/') cy.url().should('include', '/dashboard/admin/internships/edit/')
const downloadsFolder = Cypress.config("downloadsFolder");
cy.contains('Stiahnuť originálnu zmluvu').click() cy.contains('Stiahnuť originálnu zmluvu').click()
cy.wait(2000) cy.wait(2000)
}) })

View File

@@ -12,6 +12,7 @@ describe('Admin Internship CRUD', () => {
cy.contains("Praxe").click() cy.contains("Praxe").click()
cy.url().should('include', '/dashboard/admin/internships') cy.url().should('include', '/dashboard/admin/internships')
cy.wait(2000)
}) })
it('should load the list of internships in a proper format', () => { it('should load the list of internships in a proper format', () => {
@@ -64,28 +65,15 @@ describe('Admin Internship CRUD', () => {
}) })
}) })
// Ešte nie je implementované mazanie it('should be able to delete an internship', () => {
/*it('should be able to delete an internship', () => {
let initialRowCount = 0
cy.get('table tbody tr').its('length').then((count) => {
initialRowCount = count
})
cy.get('table tbody tr').first().within(() => { cy.get('table tbody tr').first().within(() => {
cy.contains('Vymazať').click() cy.get('.internship-delete-btn').click()
}) })
cy.contains("Potvrdiť vymazanie").parent().should('be.visible') cy.contains("Potvrdiť vymazanie").parent().should('be.visible')
cy.contains("Potvrdiť vymazanie").parent().contains("Vymazať").click() cy.contains("Potvrdiť vymazanie").parent().contains("Áno").click()
cy.contains("Potvrdiť vymazanie").should('not.exist') cy.contains("Potvrdiť vymazanie").should('not.exist')
cy.wait(1000) cy.wait(1000)
})
cy.get('table tbody tr').its('length').then((count) => {
expect(count).to.be.eq(initialRowCount - 1)
})
})*/
// TODO: Edit praxe
}) })