Skip to content

Commit e825813

Browse files
Bugfix/team project issue (ActiveLearningStudio#514)
* PR review fixing * CUR-1201 fixing * CUR-1203 and CUR-1201 fixing * some fixing for team projects * some fixing for team projects
1 parent 517affd commit e825813

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

Diff for: app/Http/Controllers/Api/V1/TeamController.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,15 @@ public function removeProject(TeamRemoveProjectRequest $removeProjectRequest, Te
532532
$project = $this->projectRepository->find($data['id']);
533533

534534
if ($project) {
535-
$team->projects()->detach($project);
535+
return \DB::transaction(function () use ($team, $project) {
536+
$team->projects()->detach($project);
537+
$project->delete();
538+
// $this->teamRepository->removeTeamUserProject($team, $project);
536539

537-
$this->teamRepository->removeTeamUserProject($team, $project);
538-
539-
return response([
540-
'message' => 'Project has been removed from the team successfully.',
541-
], 200);
540+
return response([
541+
'message' => 'Project has been removed from the team successfully.',
542+
], 200);
543+
});
542544
}
543545

544546
return response([
@@ -730,7 +732,7 @@ public function update(TeamUpdateRequest $teamUpdateRequest, Organization $subor
730732
*/
731733
public function updateTeamMemberRole(TeamMemberRoleUpdateRequest $request, Organization $suborganization, Team $team)
732734
{
733-
$this->authorize('updateMemberRole', [Team::class, $suborganization, $team]);
735+
$this->authorize('updateMemberRole', [Team::class, $team]);
734736

735737
$data = $request->validated();
736738

Diff for: app/Policies/TeamPolicy.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,12 @@ public function update(User $user, Organization $suborganization)
6363
* Determine whether the user can update the team member role.
6464
*
6565
* @param User $user
66-
* @param Organization $suborganization
6766
* @param Team $team
6867
* @return mixed
6968
*/
70-
public function updateMemberRole(User $user, Organization $suborganization, Team $team)
69+
public function updateMemberRole(User $user, Team $team)
7170
{
72-
return $user->hasPermissionTo('team:edit', $suborganization)
73-
|| $user->hasTeamPermissionTo('team:add-team-user', $team)
74-
|| $user->hasTeamPermissionTo('team:remove-team-user', $team);
71+
return $user->hasTeamPermissionTo('team:add-team-user', $team);
7572
}
7673

7774
/**

0 commit comments

Comments
 (0)