Skip to content

Commit

Permalink
✨ move trip creation from closed to open beta (#2427)
Browse files Browse the repository at this point in the history
Co-authored-by: Levin Herr <[email protected]>
  • Loading branch information
MrKrisKrisu and HerrLevin authored Apr 5, 2024
1 parent 46ca2e2 commit f9f3cbf
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 60 deletions.
5 changes: 4 additions & 1 deletion database/seeders/Constants/PermissionSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public function run(): void {
$roleEventModerator->givePermissionTo($permissionDenyEvents);
$roleEventModerator->givePermissionTo($permissionUpdateEvents);

//Revoke permissions from closed-beta role
$roleClosedBeta->revokePermissionTo($permissionCreateManualTrip); //now in open-beta

//Assign permissions to open-beta role
$roleClosedBeta->givePermissionTo($permissionCreateManualTrip);
$roleOpenBeta->givePermissionTo($permissionCreateManualTrip);
}
}
4 changes: 3 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -763,5 +763,7 @@
"error.419": "Zeitüberschreitung",
"error.429": "Zu viele Anfragen",
"error.500": "Interner Serverfehler",
"support.rate_limit_exceeded": "Du hast vor kurzem bereits eine Support-Anfrage erstellt. Bitte warte noch etwas, bevor du eine weitere Anfrage erstellst."
"support.rate_limit_exceeded": "Du hast vor kurzem bereits eine Support-Anfrage erstellt. Bitte warte noch etwas, bevor du eine weitere Anfrage erstellst.",
"missing-journey": "Ist deine Fahrt nicht dabei?",
"create-journey": "Fahrt erstellen"
}
4 changes: 3 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -763,5 +763,7 @@
"error.419": "Page expired",
"error.429": "Too many requests",
"error.500": "Server error",
"support.rate_limit_exceeded": "You have recently created a support request. Please wait a bit before creating another request."
"support.rate_limit_exceeded": "You have recently created a support request. Please wait a bit before creating another request.",
"missing-journey": "Haven't found your Journey?",
"create-journey": "Create journey"
}
4 changes: 0 additions & 4 deletions resources/views/admin/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class="brand-image me-3" style="width: 30px; opacity: 0.8">
<i class="fa-solid fa-train"></i>
Checkin
</a>
<a class="nav-link" href="{{ route('admin.trip.create') }}">
<i class="fa-solid fa-plus"></i>
Trips
</a>
<a class="nav-link" href="{{ route('admin.stations') }}">
<i class="fa-solid fa-map-marker"></i>
Stations
Expand Down
9 changes: 0 additions & 9 deletions resources/views/admin/trip/create.blade.php

This file was deleted.

18 changes: 18 additions & 0 deletions resources/views/beta/trip-creation.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@extends('layouts.app')

@section('title', 'Create trip manually')

@section('content')
<div class="container">
<div id="trip-creation-form">
@if(app()->getLocale() !== 'en')
<div class="alert alert-info" role="alert">
<i class="fas fa-info-circle"></i>
{{__('page-only-available-in-language', ['language' => __('language.en')])}}
</div>
@endif

<trip-creation-form></trip-creation-form>
</div>
</div>
@endsection
11 changes: 0 additions & 11 deletions resources/views/closed-beta/trip-creation.blade.php

This file was deleted.

14 changes: 13 additions & 1 deletion resources/views/stationboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,20 @@
<Stationboard
@isset($station)
station="{{$station->name}}"
station-id="{{$station->id}}"
station-id="{{$station->id}}"
@endisset></Stationboard>

<div class="text-center mt-4">
<hr/>
<p>
<span class="badge text-bg-info">Beta</span>
{{__('missing-journey')}}
</p>
<a href="{{ route('trip.create') }}" class="btn btn-sm btn-outline-secondary">
<i class="fa-solid fa-plus"></i>
{{__('create-journey')}}
</a>
</div>
@else
@include('includes.station-autocomplete')
<div id="timepicker-wrapper">
Expand Down
30 changes: 16 additions & 14 deletions resources/views/stats/stats.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,25 @@
<div class="col-lg-4">
@include('stats.includes.global_cards')

<h4>
{{__('experimental-features')}}
</h4>
<ul>
@if(auth()->check() && auth()->user()->hasRole('closed-beta'))
@if(auth()->check() && auth()->user()->hasRole('open-beta'))
<h4>
{{__('experimental-features')}}
</h4>
<ul>
@if(auth()->check() && auth()->user()->hasRole('closed-beta'))
<li>
<a href="{{route('stats.stations')}}">
{{__('stats.stations.description')}}
</a>
</li>
@endif
<li>
<a href="{{route('stats.stations')}}">
{{__('stats.stations.description')}}
<a href="{{route('stats.daily', ['dateString' => today()->toDateString()])}}">
{{__('stats.daily.description')}}
</a>
</li>
@endif
<li>
<a href="{{route('stats.daily', ['dateString' => \Illuminate\Support\Facades\Date::today()->toDateString()])}}">
{{__('stats.daily.description')}}
</a>
</li>
</ul>
</ul>
@endif
</div>
</div>
</div>
Expand Down
34 changes: 22 additions & 12 deletions resources/vue/components/TripCreation/TripCreationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
window.location.href = `/trains/trip/?${new URLSearchParams(query).toString()}`;
});
}
if(data.status === 422) {
if (data.status === 422) {
data.json().then((result) => {
alert(result.message);
});
Expand All @@ -121,20 +121,24 @@ export default {
<div>
<h1 class="fs-4">
<i class="fa fa-plus" aria-hidden="true"></i>
Create trip manually (closed-beta)
Create trip manually
</h1>

<div class="alert alert-info">
<h2 class="fs-5">
<i class="fa fa-info-circle" aria-hidden="true"></i>
Beta users only
Beta
</h2>

This form is currently for testing purposes only.
Beta users can create a trip with manually entered data.
All Users can check in to this trip.
It should be tested if the trip is created correctly and all data required for the trip is present, so no
(500) errors occur or if features are missing which are not mentioned in the limitations section.
Please note, that the creation of trips is currently in beta.
You can create trips manually by entering the stations and times.
There are some limitations, which are listed below.
<br/>
If you encounter any issues, please report them to us.
<a href="https://github.com/Traewelling/traewelling/issues/new/choose" target="_blank" class="float-end btn btn-sm btn-outline-danger">
Report issue
</a>

</div>

<form @submit.prevent="sendForm" class="mb-3">
Expand Down Expand Up @@ -166,7 +170,8 @@ export default {
</div>
<div class="row g-3 mt-1">
<div class="col-4">
<input type="text" class="form-control" placeholder="Linie (S1, ICE 13, ...)" v-model="trainTypeInput">
<input type="text" class="form-control" placeholder="Linie (S1, ICE 13, ...)"
v-model="trainTypeInput">
</div>
<div class="col-4">
<input type="text" class="form-control" placeholder="Nummer (optional)" aria-label="Fahrtnummer"
Expand All @@ -193,9 +198,14 @@ export default {
</h2>

<ul>
<li>Only stations available in DB-HAFAS are supported</li>
<li>Stopovers can't be created yet</li>
<li>Polyline is generated straight from origin to destination (Brouter generation will apply if the difference between air distance and distance by train isn't too big)</li>
<li>Only stations available in the time table of DB Navigator are supported</li>
<li>
The map lines are generated straight from the given stations
<small>(we try to find a route via Brouter, but this can be result in wrong data)</small>
</li>
<li>The trip is generally created public - so if you checkin to a trip, everyone who can see your status can ride with you.</li>
<li>The operator can't be set in this form (possible via API)</li>
<li>There are no visible error messages for this form. So, if nothing happens on submit... sorry. There is an error.</li>
</ul>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@
* All of these routes can only be used by fully registered users.
*/
Route::middleware(['auth', 'privacy'])->group(function() {
Route::view('/beta/trip-creation', 'closed-beta.trip-creation')
->can('create-manual-trip')
->name('beta.trip-creation');

Route::redirect('/beta/trip-creation', '/trip/create'); //TODO: remove after 2024-06
Route::view('/trip/create', 'beta.trip-creation')
->middleware(['can:create-manual-trip'])
->name('trip.create');

Route::post('/ics/createToken', [IcsController::class, 'createIcsToken'])
->name('ics.createToken'); //TODO: Replace with API Endpoint
Expand Down
3 changes: 0 additions & 3 deletions routes/web/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
});

Route::prefix('trip')->group(function() {
Route::view('/create', 'admin.trip.create')
->name('admin.trip.create');

Route::get('/{id}', [TripController::class, 'renderTrip'])
->name('admin.trip.show');
});
Expand Down

0 comments on commit f9f3cbf

Please sign in to comment.