You've already forked isop-mirror
Compare commits
14 Commits
d570ca3398
...
43b056f412
| Author | SHA1 | Date | |
|---|---|---|---|
| 43b056f412 | |||
|
|
b9be4a2e6c | ||
|
|
06e6e59a18 | ||
|
|
a9ac8a2735 | ||
|
|
01aae85efc | ||
|
|
b95cdb070d | ||
|
|
e64b6c2eca | ||
|
|
4a5a4f990c | ||
|
|
2b31c1d2ad | ||
|
|
b612c0f873 | ||
|
|
9de30a7df1 | ||
|
|
1d2016c011 | ||
|
|
687018e0fe | ||
|
|
6902eadef5 |
61
backend/app/Console/Commands/CreateAdmin.php
Normal file
61
backend/app/Console/Commands/CreateAdmin.php
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -123,17 +123,30 @@ class InternshipStatusDataController extends Controller
|
||||
'modified_by' => $user->id
|
||||
]);
|
||||
|
||||
// mail študentovi
|
||||
Mail::to($internship->student)
|
||||
->sendNow(new InternshipStatusUpdated(
|
||||
$internship,
|
||||
$user->name,
|
||||
$internship->student->name,
|
||||
$internship->company->name,
|
||||
$internshipStatus->status,
|
||||
$request->enum('status', InternshipStatus::class),
|
||||
$request->note
|
||||
$newStatus->status,
|
||||
$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();
|
||||
return response()->noContent();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Mail;
|
||||
|
||||
use App\Enums\InternshipStatus;
|
||||
use App\Models\Internship;
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
@@ -15,25 +16,23 @@ class InternshipStatusUpdated extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
private Internship $internship;
|
||||
private string $changedByName;
|
||||
private string $studentName;
|
||||
private string $companyName;
|
||||
private InternshipStatus $oldStatus;
|
||||
private InternshipStatus $newStatus;
|
||||
private string $note;
|
||||
private User $changedBy;
|
||||
private bool $recipiantIsStudent;
|
||||
|
||||
/**
|
||||
* 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->changedByName = $changedByName;
|
||||
$this->studentName = $studentName;
|
||||
$this->companyName = $companyName;
|
||||
$this->oldStatus = $oldStatus;
|
||||
$this->newStatus = $newStatus;
|
||||
$this->note = $note;
|
||||
$this->changedBy = $changedBy;
|
||||
$this->recipiantIsStudent = $recipiantIsStudent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,12 +54,11 @@ class InternshipStatusUpdated extends Mailable
|
||||
view: 'mail.internship.status_updated',
|
||||
with: [
|
||||
"internship" => $this->internship,
|
||||
"changedByName" => $this->changedByName,
|
||||
"studentName" => $this->studentName,
|
||||
"companyName" => $this->companyName,
|
||||
"oldStatus" => $this->prettyStatus($this->oldStatus->value),
|
||||
"newStatus" => $this->prettyStatus($this->newStatus->value),
|
||||
"note" => $this->note,
|
||||
"recipiantIsStudent" => $this->recipiantIsStudent,
|
||||
"changedBy" => $this->changedBy,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Company extends Model
|
||||
/**
|
||||
* Get the contact person (user) for the company.
|
||||
*/
|
||||
public function contact()
|
||||
public function contactPerson()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'contact');
|
||||
}
|
||||
|
||||
@@ -107,6 +107,10 @@ class Internship extends Model
|
||||
$current_status === InternshipStatus::CONFIRMED_BY_ADMIN && $userRole === "ADMIN" && !$report_confirmed
|
||||
=> ['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
|
||||
$current_status === InternshipStatus::DEFENDED && $userRole === "ADMIN"
|
||||
=> ['NOT_DEFENDED'],
|
||||
|
||||
@@ -18,7 +18,7 @@ class CompanyFactory extends Factory
|
||||
{
|
||||
return [
|
||||
'name' => fake()->company(),
|
||||
'address' => fake()->address(),
|
||||
'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
|
||||
'ico' => fake()->numberBetween(111111, 999999),
|
||||
'contact' => 0,
|
||||
'hiring' => fake()->boolean(),
|
||||
|
||||
@@ -18,7 +18,7 @@ class StudentDataFactory extends Factory
|
||||
{
|
||||
return [
|
||||
'user_id' => 0,
|
||||
'address' => fake()->address(),
|
||||
'address' => fake()->streetAddress() . ", " . fake()->city() . ", " . fake()->postcode(),
|
||||
'personal_email' => fake()->safeEmail(),
|
||||
'study_field' => fake()->randomElement(["AI22m", "AI22b"]),
|
||||
];
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
@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>Zmenu vykonal <em>{{ $changedBy->name }}</em>.</p>
|
||||
<br />
|
||||
|
||||
<p>s pozdravom</p>
|
||||
<p>S pozdravom.</p>
|
||||
<p>Systém ISOP UKF</p>
|
||||
@include("parts.footer")
|
||||
@@ -25,6 +25,11 @@ const totalItems = ref(0);
|
||||
const deleteConfirmDialog = ref(false);
|
||||
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 = [
|
||||
{ title: "Študent", key: "student.name", sortable: false },
|
||||
{ title: "Firma", key: "company.name", sortable: false },
|
||||
@@ -99,16 +104,20 @@ async function confirmDeletion(confirm: boolean) {
|
||||
|
||||
<v-row>
|
||||
<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 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 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 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-row>
|
||||
|
||||
@@ -127,13 +136,13 @@ async function confirmDeletion(confirm: boolean) {
|
||||
<v-tooltip text="Editovať">
|
||||
<template #activator="{ props }">
|
||||
<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>
|
||||
</v-tooltip>
|
||||
<v-tooltip text="Vymazať" v-if="mode === 'admin'">
|
||||
<template #activator="{ props }">
|
||||
<v-btn icon="mdi-delete" size="small" variant="text" color="error"
|
||||
@click="() => openDeleteDialog(item)" />
|
||||
@click="() => openDeleteDialog(item)" class="internship-delete-btn" />
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</template>
|
||||
|
||||
@@ -19,7 +19,8 @@ useSeoMeta({
|
||||
const rules = {
|
||||
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
|
||||
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ť',
|
||||
};
|
||||
|
||||
@@ -101,8 +102,8 @@ async function handleRegistration() {
|
||||
density="comfortable" />
|
||||
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
|
||||
variant="outlined" density="comfortable" />
|
||||
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón:" variant="outlined"
|
||||
density="comfortable" />
|
||||
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón (s predvoľbou):"
|
||||
variant="outlined" density="comfortable" />
|
||||
|
||||
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
|
||||
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />
|
||||
|
||||
@@ -23,11 +23,14 @@ const rules = {
|
||||
personal_email: (v: string) =>
|
||||
/.+@.+\..+/.test(v) || 'Zadajte platný osobný email',
|
||||
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ť',
|
||||
};
|
||||
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);
|
||||
@@ -38,10 +41,11 @@ const form = ref({
|
||||
studentEmail: '',
|
||||
personalEmail: '',
|
||||
phone: '',
|
||||
studyProgram: programs[0] as string,
|
||||
studyProgram: programs[0]!.value,
|
||||
year_of_study: 1,
|
||||
consent: false,
|
||||
});
|
||||
const maxYearOfStudy = ref(0);
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref(null as null | string);
|
||||
@@ -80,6 +84,10 @@ async function handleRegistration() {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(form, (newForm) => {
|
||||
maxYearOfStudy.value = newForm.studyProgram.slice(-1) === 'b' ? 3 : 2;
|
||||
}, { deep: true, immediate: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -109,14 +117,14 @@ async function handleRegistration() {
|
||||
<v-text-field v-model="form.personalEmail" :rules="[rules.required, rules.personal_email]"
|
||||
label="Alternatívny email:" variant="outlined" density="comfortable" />
|
||||
|
||||
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]" label="Telefón:"
|
||||
variant="outlined" density="comfortable" />
|
||||
<v-text-field v-model="form.phone" :rules="[rules.required, rules.phone]"
|
||||
label="Telefón (s predvoľbou):" variant="outlined" density="comfortable" />
|
||||
|
||||
<v-select v-model="form.studyProgram" :items="programs" :rules="[rules.required]"
|
||||
label="Študijný odbor:" variant="outlined" density="comfortable" />
|
||||
|
||||
<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]"
|
||||
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />
|
||||
|
||||
@@ -12,6 +12,7 @@ describe('Admin Student Document Downloads', () => {
|
||||
|
||||
cy.contains("Praxe").click()
|
||||
cy.url().should('include', '/dashboard/admin/internships')
|
||||
cy.wait(2000)
|
||||
})
|
||||
|
||||
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('td').contains('Editovať').click()
|
||||
cy.get('td').get('.internship-edit-btn').click()
|
||||
})
|
||||
})
|
||||
|
||||
cy.url().should('include', '/dashboard/admin/internships/edit/')
|
||||
|
||||
const downloadsFolder = Cypress.config("downloadsFolder");
|
||||
cy.contains('Stiahnuť originálnu zmluvu').click()
|
||||
cy.wait(2000)
|
||||
})
|
||||
|
||||
@@ -12,6 +12,7 @@ describe('Admin Internship CRUD', () => {
|
||||
|
||||
cy.contains("Praxe").click()
|
||||
cy.url().should('include', '/dashboard/admin/internships')
|
||||
cy.wait(2000)
|
||||
})
|
||||
|
||||
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', () => {
|
||||
let initialRowCount = 0
|
||||
|
||||
cy.get('table tbody tr').its('length').then((count) => {
|
||||
initialRowCount = count
|
||||
})
|
||||
|
||||
it('should be able to delete an internship', () => {
|
||||
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().contains("Vymazať").click()
|
||||
cy.contains("Potvrdiť vymazanie").parent().contains("Áno").click()
|
||||
cy.contains("Potvrdiť vymazanie").should('not.exist')
|
||||
|
||||
cy.wait(1000)
|
||||
|
||||
cy.get('table tbody tr').its('length').then((count) => {
|
||||
expect(count).to.be.eq(initialRowCount - 1)
|
||||
})
|
||||
})*/
|
||||
|
||||
// TODO: Edit praxe
|
||||
})
|
||||
Reference in New Issue
Block a user