Skip to content

Commit

Permalink
feat: telegram group links (#661)
Browse files Browse the repository at this point in the history
* feat: telegram group links

* fix: pr review comments

* fix: use array_key_exists instead of in_array

---------

Co-authored-by: Tobias Grether <[email protected]>
  • Loading branch information
simonostendorf and TobiasGrether authored Sep 8, 2024
1 parent 1f99444 commit 34af4db
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('groups', function (Blueprint $table) {
$table->string('telegram_group_link')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('groups', function (Blueprint $table) {
$table->dropColumn(['telegram_group_link']);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('slots', function (Blueprint $table) {
$table->string('telegram_group_link')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('slots', function (Blueprint $table) {
$table->dropColumn(['telegram_group_link']);
});
}
};
7 changes: 7 additions & 0 deletions database/seeders/EventsDemoSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function runGroupPhase(): void
for ($i = 1; $i <= 14; $i++) {
$groups[] = [
'name' => "Gruppe $i",
'telegram_group_link' => "https://example.com/invalid-telegram-link",
];
}

Expand All @@ -67,6 +68,7 @@ public function runGroupPhase(): void
$group = new Group;
$group->name = $groupData['name'];
$group->event_id = $event->id;
$group->telegram_group_link = $groupData['telegram_group_link'];
$group->save();
}

Expand Down Expand Up @@ -251,21 +253,25 @@ public function runSlotBooking(): void
'name' => 'Lorem ipsum',
'has_requirements' => true,
'maximum_participants' => 10,
'telegram_group_link' => "https://example.com/invalid-telegram-link",
],
[
'name' => 'Dolor sit',
'has_requirements' => true,
'maximum_participants' => 20,
'telegram_group_link' => "https://example.com/invalid-telegram-link",
],
[
'name' => 'Amet consectetur',
'has_requirements' => true,
'maximum_participants' => 30,
'telegram_group_link' => "https://example.com/invalid-telegram-link",
],
[
'name' => 'Adipiscing elit',
'has_requirements' => true,
'maximum_participants' => 40,
'telegram_group_link' => "https://example.com/invalid-telegram-link",
],
[
'name' => 'Sed vitae eros',
Expand All @@ -291,6 +297,7 @@ public function runSlotBooking(): void
$slot->event_id = $event->id;
$slot->has_requirements = $slotData['has_requirements'];
$slot->maximum_participants = $slotData['maximum_participants'];
$slot->telegram_group_link = in_array('telegram_group_link', $slotData) ? $slotData['telegram_group_link'] : null;

$slot->save();
}
Expand Down
70 changes: 62 additions & 8 deletions database/seeders/EventsErstiwocheSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function runStadtrallye(): void
$event->description = '<p>Die Stadtrallye ist ein Event, bei dem du in Gruppen die Stadt erkundest. Dabei gibt es verschiedene Aufgaben, die ihr lösen müsst. Dabei könnt ihr euch gegenseitig unterstützen und euch so besser kennenlernen.</p><p><strong>Treffpunkt: </strong> 9:00 Uhr Campus Eupener Straße</p>';
$event->type = 'group_phase';
$event->registration_from = new DateTime('2023-09-25 8:00:00');
$event->registration_to = new DateTime('2023-09-26 10:00:00');
$event->registration_to = new DateTime('2024-09-26 10:00:00');
$event->has_requirements = false;
$event->consider_alcohol = true;
$event->sort_order = 110;
Expand All @@ -107,19 +107,71 @@ public function runStadtrallye(): void
$event->save();

// create event groups
$groups = [];

for ($i = 1; $i <= 14; $i++) {
$groups[] = [
'name' => "Gruppe $i",
];
}
$groups = [
[
'name' => "Gruppe 1",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 2",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 3",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 4",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 5",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 6",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 7",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 8",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 9",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 10",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 11",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 12",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 13",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
[
'name' => "Gruppe 14",
'telegram_group_link' => "https://example.com/invalid-telegram-link"
]
];

// save groups
foreach ($groups as $groupData) {
$group = new Group;
$group->name = $groupData['name'];
$group->event_id = $event->id;
$group->telegram_group_link = array_key_exists('telegram_group_link', $groupData) ? $groupData['telegram_group_link'] : null;
$group->save();
}
}
Expand Down Expand Up @@ -329,6 +381,7 @@ public function runSport(): void
'name' => 'Lasertag',
'has_requirements' => true,
'maximum_participants' => 57,
'telegram_group_link' => "https://example.com/invalid-telegram-link"
],
];

Expand All @@ -338,6 +391,7 @@ public function runSport(): void
$slot->event_id = $event->id;
$slot->has_requirements = $slotData['has_requirements'];
$slot->maximum_participants = $slotData['maximum_participants'];
$slot->telegram_group_link = array_key_exists('telegram_group_link', $slotData) ? $slotData['telegram_group_link'] : null;

$slot->save();
}
Expand Down
2 changes: 2 additions & 0 deletions database/seeders/tutors.csv.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lastname;firstname;course;email;roles;disabled
Mustermann;Max;INF;[email protected];super admin|admin|stage tutor;0
9 changes: 7 additions & 2 deletions resources/js/components/ui/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
}"
class="text-sm font-medium"
>
<div v-html="message"></div>
<slot name="message">
<div v-html="message"></div>
</slot>
</div>
</div>
</div>
Expand All @@ -56,7 +58,6 @@ import { computed } from "vue";
const { type } = defineProps({
message: {
type: String,
required: true,
},
type: {
type: String,
Expand All @@ -66,6 +67,10 @@ const { type } = defineProps({
},
});
defineSlots<{
message?: HTMLElement;
}>();
const icon = computed(() => {
if (type === "success") return "circle-check";
if (type === "error") return "circle-xmark";
Expand Down
63 changes: 45 additions & 18 deletions resources/js/pages/Dashboard/Event/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,36 @@
userRegistration.fulfils_requirements)
"
type="success"
:message="
'Die Einteilung ist erfolgt. Du bist in ' +
(userRegistration.group.name
? 'der Gruppe <strong>' +
userRegistration.group.name +
'</strong>'
: '<strong>Gruppe ' +
userRegistration.group.id +
'</strong>') +
'.'
"
/>
>
<template #message>
<template v-if="userRegistration.group.name">
Die Einteilung ist erfolgt. Du bist in der Gruppe
<strong>{{ userRegistration.group.name }}</strong
>.
<div v-if="userRegistration.group.telegram_group_link">
<AppLink
:href="userRegistration.group.telegram_group_link"
rootClass="inline"
>Klicke hier</AppLink
>
um der Telegram Gruppe beizutreten.
</div>
</template>
<template v-else>
Die Einteilung ist erfolgt. Du bist in
<strong>Gruppe {{ userRegistration.group.id }}</strong
>.
<div v-if="userRegistration.group.telegram_group_link">
<AppLink
:href="userRegistration.group.telegram_group_link"
rootClass="inline"
>Klicke hier</AppLink
>
um der Telegram Gruppe beizutreten.
</div>
</template>
</template>
</UiMessage>
<UiMessage
v-else
type="warning"
Expand Down Expand Up @@ -99,12 +117,21 @@
userRegistration.fulfils_requirements)
"
type="success"
:message="
'Die Einteilung ist erfolgt. Du bist im Slot <strong>' +
slotData.name +
'</strong>.'
"
/>
>
<template #message>
Die Einteilung ist erfolgt. Du bist im Slot
<strong>{{ slotData.name }}</strong
>.
<div v-if="slotData.telegram_group_link">
<AppLink
:href="slotData.telegram_group_link"
rootClass="inline"
>Klicke hier</AppLink
>
um der Telegram Gruppe beizutreten.
</div>
</template>
</UiMessage>
<UiMessage
v-else
type="warning"
Expand Down
8 changes: 8 additions & 0 deletions resources/js/pages/Dashboard/Tutor/Group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
<LayoutDashboardContent>
<template #title>{{ group.name }}</template>
<CardContainer>
<CardBase v-if="group.telegram_group_link">
<UiH2>Telegram Gruppe</UiH2>
Für diese Gruppe wurde eine Telegram Gruppe erstellt. Diesen Link sehen
nur Gruppenmitglieder und Tutoren.
<AppLink :href="group.telegram_group_link">
{{ group.telegram_group_link }}
</AppLink>
</CardBase>
<CardBase>
<FormKit type="form" id="assign" :actions="false" v-model="form">
<FormContainer>
Expand Down
8 changes: 8 additions & 0 deletions resources/js/pages/Dashboard/Tutor/Slot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
<LayoutDashboardContent>
<template #title>{{ slot.name }}</template>
<CardContainer>
<CardBase v-if="slot.telegram_group_link">
<UiH2>Telegram Gruppe</UiH2>
Für diesen Slot wurde eine Telegram Gruppe erstellt. Diesen Link sehen
nur Slotmitglieder und Tutoren.
<AppLink :href="slot.telegram_group_link">
{{ slot.telegram_group_link }}
</AppLink>
</CardBase>
<CardBase>
<FormKit type="form" id="assign" :actions="false" v-model="form">
<FormContainer>
Expand Down

0 comments on commit 34af4db

Please sign in to comment.