Skip to content

Commit

Permalink
Merge pull request #647 from TheRestartProject/RES-1885_vue_event_cre…
Browse files Browse the repository at this point in the history
…ate_edit

RES-1885 Rework event add/edit page to use API
  • Loading branch information
edwh authored Aug 2, 2023
2 parents eef963f + 88a79e3 commit 324dbaf
Show file tree
Hide file tree
Showing 25 changed files with 537 additions and 523 deletions.
19 changes: 12 additions & 7 deletions app/Helpers/Fixometer.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static function userHasDeletePartyPermission($partyId, $userId = null)
return false;
}

public static function userCanApproveEvent($eventId, $userId = null)
public static function userCanApproveEvent($eventId, $userId = null, $groupId = null)
{
if (is_null($userId)) {
$userId = Auth::user()->id;
Expand All @@ -200,7 +200,12 @@ public static function userCanApproveEvent($eventId, $userId = null)
}

if (self::hasRole($user, 'NetworkCoordinator')) {
$group = Party::find($eventId)->theGroup;
if ($groupId) {
$group = Group::find($groupId);
} else {
$group = Party::find($eventId)->theGroup;
}

foreach ($group->networks as $network) {
if ($network->coordinators->contains($user)) {
return true;
Expand Down Expand Up @@ -248,22 +253,22 @@ public static function userHasEditEventsDevicesPermission($partyId, $userId = nu

public static function userCanCreateEvents($user)
{
if (Auth::guest()) {
return false;
}

if (is_null($user)) {
$user = Auth::user();
}

if (!$user) {
return false;
}

$usersRole = $user->role()->first()->role;
$superusers = ['Root', 'Administrator', 'NetworkCoordinator'];

if (in_array($usersRole, $superusers)) {
return true;
}

$userIsHostOfAGroup = UserGroups::where('user', Auth::user()->id)
$userIsHostOfAGroup = UserGroups::where('user', $user->id)
->where('role', 3)
->count() > 0;

Expand Down
20 changes: 12 additions & 8 deletions app/Http/Controllers/API/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,6 @@ public function getEventv2(Request $request, $idevents)
{
$party = Party::findOrFail($idevents);

if (!$party->theGroup->approved) {
abort(404);
}

return \App\Http\Resources\Party::make($party);
}

Expand Down Expand Up @@ -421,6 +417,10 @@ public function moderateEventsv2(Request $request)
* property="online",
* ref="#/components/schemas/Event/properties/online",
* ),
* @OA\Property(
* property="link",
* ref="#/components/schemas/Event/properties/link",
* ),
* )
* )
* ),
Expand Down Expand Up @@ -580,6 +580,10 @@ public function createEventv2(Request $request)
* property="online",
* ref="#/components/schemas/Event/properties/online",
* ),
* @OA\Property(
* property="link",
* ref="#/components/schemas/Event/properties/link",
* ),
* )
* )
* ),
Expand Down Expand Up @@ -648,8 +652,8 @@ private function validateEventParams(Request $request, $create): array
if ($create) {
$request->validate([
'groupid' => 'required|integer',
'start' => ['required', 'date_format:Y-m-d\TH:i:sP'],
'end' => ['required', 'date_format:Y-m-d\TH:i:sP'],
'start' => ['required', 'date_format:Y-m-d\TH:i:sP,Y-m-d\TH:i:s\Z'],
'end' => ['required', 'date_format:Y-m-d\TH:i:sP,Y-m-d\TH:i:s\Z'],
'title' => ['required', 'max:255'],
'description' => ['required'],
'location' => [
Expand All @@ -663,8 +667,8 @@ function ($attribute, $value, $fail) use ($request) {
]);
} else {
$request->validate([
'start' => ['required', 'date_format:Y-m-d\TH:i:sP'],
'end' => ['required', 'date_format:Y-m-d\TH:i:sP'],
'start' => ['required', 'date_format:Y-m-d\TH:i:sP,Y-m-d\TH:i:s\Z'],
'end' => ['required', 'date_format:Y-m-d\TH:i:sP,Y-m-d\TH:i:s\Z'],
'title' => ['required', 'max:255'],
'description' => ['required'],
'location' => [
Expand Down
Loading

0 comments on commit 324dbaf

Please sign in to comment.