From 2005ca71201b30079cd6c048e2cb067aedbc578b Mon Sep 17 00:00:00 2001 From: Werner Date: Wed, 9 Mar 2016 19:25:34 +0100 Subject: [PATCH 1/4] Fixed a few style issues --- resources/views/layouts/app.blade.php | 2 +- resources/views/syndie/contract/view.blade.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 7dcf7da..ff5c377 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -57,7 +57,7 @@ - Aurora Webinterface + Aurora WI diff --git a/resources/views/syndie/contract/view.blade.php b/resources/views/syndie/contract/view.blade.php index a57b0fc..b3772db 100644 --- a/resources/views/syndie/contract/view.blade.php +++ b/resources/views/syndie/contract/view.blade.php @@ -46,7 +46,7 @@ {{-- Contract Overview --}}
{{-- Details about the contract--}} -
+

{{$contract->title}}

@@ -73,7 +73,7 @@ {{--
--}}
- @if(Auth::user()->cannot('contract_moderate'))
@else()
@endif() + @if(Auth::user()->cannot('contract_moderate'))
@else()
@endif()
Contract Description:
@@ -84,7 +84,7 @@
{{-- Management Panel--}} @if(Auth::user()->can('contract_moderate')) -
+
Actions
From b58b0ec0ad1039997e0c1e596f44a200d44cfb2a Mon Sep 17 00:00:00 2001 From: Werner Date: Wed, 9 Mar 2016 19:49:59 +0100 Subject: [PATCH 2/4] Fixed a few bugs and added a laravel datatable to the index page --- .../Controllers/Syndie/ContractController.php | 21 ++++++++-- app/Http/routes.php | 1 + resources/views/admin/form/index.blade.php | 4 +- resources/views/syndie/contract/add.blade.php | 4 ++ .../views/syndie/contract/index.blade.php | 42 +++++++++++-------- .../views/syndie/contract/view.blade.php | 19 +++++---- 6 files changed, 62 insertions(+), 29 deletions(-) diff --git a/app/Http/Controllers/Syndie/ContractController.php b/app/Http/Controllers/Syndie/ContractController.php index 11949a2..71d91d5 100644 --- a/app/Http/Controllers/Syndie/ContractController.php +++ b/app/Http/Controllers/Syndie/ContractController.php @@ -27,20 +27,35 @@ use App\Models\SyndieContract; use App\Models\SyndieContractComment; +use Yajra\Datatables\Datatables; class ContractController extends Controller { public function index(Request $request) { + + + return view('syndie.contract.index'); + } + + public function getContractData(Request $request) + { +// $forms = ServerForm::select(['form_id','id', 'name', 'department']); + $contracts = SyndieContract::select(['contract_id','title','contractee_name','status']); //For contract mods: Show all contracts if ($request->user()->can('contract_moderate')) { - $contracts = SyndieContract::all(); + } else //For normal users: Show all contracts that have a status of open, assigned, completed, confirmed or that they own { - $contracts = SyndieContract::whereIn('status', ['open', 'assigned', 'completed', 'confirmed'])->OrWhere('contractee_id', '=', $request->user()->user_id)->get(); + $contracts->whereIn('status', ['open', 'assigned', 'completed', 'confirmed'])->OrWhere('contractee_id', '=', $request->user()->user_id)->get(); } - return view('syndie.contract.index', ['contracts' => $contracts]); + + + return Datatables::of($contracts) + ->editColumn('title', '{{$title}}') + ->editColumn('contractee_name','{{$contractee_name}}') + ->make(); } public function getAdd() diff --git a/app/Http/routes.php b/app/Http/routes.php index 4cd06ae..04aee1f 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -69,6 +69,7 @@ Route::get('/{comment}/reopen', ['as' => 'syndie.contracts.reopen', 'uses'=>'Syndie\ContractController@reopen']); // Reopen the contract Route::get('/{comment}/reopen', ['as' => 'syndie.contracts.reopen', 'uses'=>'Syndie\ContractController@reopen']); // Reopen the contract Route::get('/{comment}/delete',['as' => 'syndie.contracts.delete', 'uses'=>'Syndie\ContractController@deleteMessage']); //Delete a comment + Route::get('/data',['as' => 'syndie.contracts.data', 'uses'=>'Syndie\ContractController@getContractData']); }); }); diff --git a/resources/views/admin/form/index.blade.php b/resources/views/admin/form/index.blade.php index c05e046..f655d59 100644 --- a/resources/views/admin/form/index.blade.php +++ b/resources/views/admin/form/index.blade.php @@ -30,7 +30,7 @@
@can('admin_forms_edit')

Add new Form

@endcan() - +
@@ -51,7 +51,7 @@ + + +@endsection diff --git a/resources/views/syndie/contract/view.blade.php b/resources/views/syndie/contract/view.blade.php index b3772db..c671065 100644 --- a/resources/views/syndie/contract/view.blade.php +++ b/resources/views/syndie/contract/view.blade.php @@ -124,7 +124,7 @@

Mod OOC: {{$comment->title}}

- 11 hours ago + {{ $comment->created_at->diffForHumans() }} Made by: {{$comment->commentor_name}}

@@ -140,7 +140,7 @@

Private: {{$comment->title}}

- 11 hours ago + {{ $comment->created_at->diffForHumans() }} Made by: {{$comment->commentor_name}}

@@ -156,7 +156,7 @@

Message: {{$comment->title}}

- 11 hours ago + {{ $comment->created_at->diffForHumans() }} Made by: {{$comment->commentor_name}}

@@ -172,7 +172,7 @@

Completion Report: {{$comment->title}}

- 11 hours ago + {{ $comment->created_at->diffForHumans() }} Made by: {{$comment->commentor_name}}

@@ -194,7 +194,7 @@

Failure Report: {{$comment->title}}

- 11 hours ago + {{ $comment->created_at->diffForHumans() }} Made by: {{$comment->commentor_name}}

@@ -210,7 +210,7 @@

Contract Canceled: {{$comment->title}}

- 11 hours ago + {{ $comment->created_at->diffForHumans() }} Made by: {{$comment->commentor_name}}

@@ -226,7 +226,7 @@

OOC Message: {{$comment->title}}

- 11 hours ago + {{ $comment->created_at->diffForHumans() }} Made by: {{$comment->commentor_name}}

@@ -248,6 +248,11 @@
New Message
+
+ × + You can use Markdown to in the comment field +
+ {{ Form::open(array('route' => array('syndie.contracts.addmessage',$contract->contract_id),'method' => 'post')) }} {{Form::token()}} From 13d4acdeef65ca2fa4f1945eb946c82fc8ace42d Mon Sep 17 00:00:00 2001 From: Werner Date: Wed, 9 Mar 2016 19:50:57 +0100 Subject: [PATCH 3/4] Bumped version to 0.0.4 --- resources/views/layouts/app.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index ff5c377..d16f41e 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -147,7 +147,7 @@
From da720c152cacd7163695c2a1dd26666225cc34de Mon Sep 17 00:00:00 2001 From: Werner Date: Wed, 9 Mar 2016 20:41:13 +0100 Subject: [PATCH 4/4] Added a Edit Contract page Added the ability to delete comments Display the proper time of a comment Added markdown parsing to contract comments --- .../Controllers/Syndie/ContractController.php | 69 ++++++++++++++----- app/Http/routes.php | 4 +- .../views/syndie/contract/edit.blade.php | 42 +++++++++++ .../views/syndie/contract/view.blade.php | 47 ++++++++----- 4 files changed, 125 insertions(+), 37 deletions(-) create mode 100644 resources/views/syndie/contract/edit.blade.php diff --git a/app/Http/Controllers/Syndie/ContractController.php b/app/Http/Controllers/Syndie/ContractController.php index 71d91d5..bf6e819 100644 --- a/app/Http/Controllers/Syndie/ContractController.php +++ b/app/Http/Controllers/Syndie/ContractController.php @@ -41,7 +41,7 @@ public function index(Request $request) public function getContractData(Request $request) { // $forms = ServerForm::select(['form_id','id', 'name', 'department']); - $contracts = SyndieContract::select(['contract_id','title','contractee_name','status']); + $contracts = SyndieContract::select(['contract_id', 'title', 'contractee_name', 'status']); //For contract mods: Show all contracts if ($request->user()->can('contract_moderate')) { @@ -50,11 +50,9 @@ public function getContractData(Request $request) $contracts->whereIn('status', ['open', 'assigned', 'completed', 'confirmed'])->OrWhere('contractee_id', '=', $request->user()->user_id)->get(); } - - return Datatables::of($contracts) ->editColumn('title', '{{$title}}') - ->editColumn('contractee_name','{{$contractee_name}}') + ->editColumn('contractee_name', '{{$contractee_name}}') ->make(); } @@ -108,7 +106,31 @@ public function show($contract) public function getEdit(Request $request, $contract) { - return "Edit: " . $contract; + $SyndieContract = SyndieContract::find($contract); + + //Check if the user is the contract owner or a moderator + if ($request->user()->cannot('contract_moderate' && $request->user()->user_id != $SyndieContract->contractee_id)) { + abort(502,"You do not have the permission to edit the contract"); + } + + return view('syndie.contract.edit', ['contract' => $SyndieContract]); + } + + public function postEdit(Request $request, $contract) + { + $SyndieContract = SyndieContract::find($contract); + + //Check if the user is the contract owner or a moderator + if ($request->user()->cannot('contract_moderate' && $request->user()->user_id != $SyndieContract->contractee_id)) { + abort(502,"You do not have the permission to edit the contract"); + } + + $SyndieContract->title = $request->input('title'); + $SyndieContract->description = $request->input('description'); + $SyndieContract->save(); + + return redirect()->route('syndie.contracts.show',['contract'=>$SyndieContract->contract_id]); + } public function approve(Request $request, $contract) @@ -125,8 +147,10 @@ public function approve(Request $request, $contract) $SystemComment->commentor_id = 0; $SystemComment->commentor_name = "System"; $SystemComment->title = "Contract Approved"; - $SystemComment->comment = "The contract has been approved by a contract moderator. - Contractors are now able to see it in the contract overview."; + $SystemComment->comment = +"The contract has been approved by a contract moderator. + +Contractors are now able to see it in the contract overview."; $SystemComment->type = 'ic'; $SystemComment->save(); @@ -156,8 +180,7 @@ public function confirm(Request $request, $comment) $SyndieContract = SyndieContract::find($SyndieComment->contract_id); //Check if contract is completed - if($SyndieContract->status !== "completed") - { + if ($SyndieContract->status !== "completed") { return redirect()->route('syndie.contracts.show', ['contract' => $SyndieComment->contract_id])->withErrors(array('You can not confirm a contract as complented when no completion report has been posted')); } @@ -177,9 +200,12 @@ public function confirm(Request $request, $comment) $SystemComment->commentor_id = 0; $SystemComment->commentor_name = "System"; $SystemComment->title = "Contract Confirmed as Completed"; - $SystemComment->comment = "The contractee has confirmed that the contract has been completed by the contractor. - The funds have been transfered to the contractor. - Thank you for choosing our Contract Service."; + $SystemComment->comment = +"The contractee has confirmed that the contract has been completed by the contractor. + +The funds have been transfered to the contractor. + +Thank you for choosing our Contract Service."; $SystemComment->type = 'ic'; $SystemComment->save(); @@ -193,8 +219,7 @@ public function reopen(Request $request, $comment) $SyndieContract = SyndieContract::find($SyndieComment->contract_id); //Check if contract is completed - if($SyndieContract->status !== "completed") - { + if ($SyndieContract->status !== "completed") { return redirect()->route('syndie.contracts.show', ['contract' => $SyndieComment->contract_id])->withErrors(array('You can not reopen a contract when no completion report has been posted')); } @@ -214,9 +239,12 @@ public function reopen(Request $request, $comment) $SystemComment->commentor_id = 0; $SystemComment->commentor_name = "System"; $SystemComment->title = "Contract Reopened"; - $SystemComment->comment = "The contractee has rejected the completion report. - The contract has been reopened. - The contractee is expected to provide a explanation, why the completion report is not satisfying"; + $SystemComment->comment = +"The contractee has rejected the completion report. + +The contract has been reopened. + +The contractee is expected to provide a explanation, why the completion report is not satisfying"; $SystemComment->type = 'ic'; $SystemComment->save(); } @@ -249,7 +277,7 @@ public function addMessage($contract, Request $request) //User can not specify a name and can use only the following message types: 'ic'=>'IC Comment','ooc' => 'OOC Comment','mod-author'=>'MOD-Author PM' $commentor_name = $SyndieContract->contractee_name; - $useable = array('ic', 'ic-cancel','ooc', 'mod-author'); + $useable = array('ic', 'ic-cancel', 'ooc', 'mod-author'); if (!in_array($type, $useable)) { return redirect()->route('syndie.contracts.show', ['contract' => $contract])->withErrors(array('You are not authorized to use this message type')); } @@ -261,6 +289,11 @@ public function addMessage($contract, Request $request) } } + //Check if the message type is ooc or mod-author or mod-ooc, then set the author name to the users form username + if (in_array($type, array('ooc', 'mod-author', 'mod-ooc'))) { + $commentor_name = $request->user()->username; + } + // Post the comment $SyndieContractComment = new SyndieContractComment(); $SyndieContractComment->contract_id = $SyndieContract->contract_id; diff --git a/app/Http/routes.php b/app/Http/routes.php index 04aee1f..ed0226f 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -62,13 +62,13 @@ route::post('/add', ['as' => 'syndie.contracts.add.post', 'uses'=>'Syndie\ContractController@postAdd']); Route::get('/{contract}/show', ['as' => 'syndie.contracts.show', 'uses'=>'Syndie\ContractController@show']); Route::get('/{contract}/edit', ['as' => 'syndie.contracts.edit.get', 'uses'=>'Syndie\ContractController@getEdit']); + Route::post('/{contract}/edit', ['as' => 'syndie.contracts.edit.post', 'uses'=>'Syndie\ContractController@postEdit']); Route::get('/{contract}/approve', ['as' => 'syndie.contracts.approve', 'uses'=>'Syndie\ContractController@approve']); //Mod Approve the contract Route::get('/{contract}/reject', ['as' => 'syndie.contracts.reject', 'uses'=>'Syndie\ContractController@reject']); //Mod Reject the contract Route::post('/{contract}/addmessage',['as' => 'syndie.contracts.addmessage', 'uses'=>'Syndie\ContractController@addMessage']); //Add message to contract Route::get('/{comment}/confirm', ['as' => 'syndie.contracts.confirm', 'uses'=>'Syndie\ContractController@confirm']); //Confirm Completion of the Contract Route::get('/{comment}/reopen', ['as' => 'syndie.contracts.reopen', 'uses'=>'Syndie\ContractController@reopen']); // Reopen the contract - Route::get('/{comment}/reopen', ['as' => 'syndie.contracts.reopen', 'uses'=>'Syndie\ContractController@reopen']); // Reopen the contract - Route::get('/{comment}/delete',['as' => 'syndie.contracts.delete', 'uses'=>'Syndie\ContractController@deleteMessage']); //Delete a comment + Route::get('/{comment}/delete',['as' => 'syndie.contracts.deletemessage', 'uses'=>'Syndie\ContractController@deleteMessage']); //Delete a comment Route::get('/data',['as' => 'syndie.contracts.data', 'uses'=>'Syndie\ContractController@getContractData']); }); }); diff --git a/resources/views/syndie/contract/edit.blade.php b/resources/views/syndie/contract/edit.blade.php new file mode 100644 index 0000000..94d9275 --- /dev/null +++ b/resources/views/syndie/contract/edit.blade.php @@ -0,0 +1,42 @@ +{{--Copyright (c) 2016 "Werner Maisl"--}} + +{{--This file is part of the Aurora Webinterface--}} + +{{--The Aurora Webinterface is free software: you can redistribute it and/or modify--}} +{{--it under the terms of the GNU Affero General Public License as--}} +{{--published by the Free Software Foundation, either version 3 of the--}} +{{--License, or (at your option) any later version.--}} + +{{--This program is distributed in the hope that it will be useful,--}} +{{--but WITHOUT ANY WARRANTY; without even the implied warranty of--}} +{{--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--}} +{{--GNU Affero General Public License for more details.--}} + +{{--You should have received a copy of the GNU Affero General Public License--}} +{{--along with this program. If not, see .--}} + +@extends('layouts.app') + +@section('content') +
+
+
+
+
Edit Contract: {{$contract->title}}
+ +
+ {{Form::model($contract, array('route' => array('syndie.contracts.edit.post', $contract->contract_id),'method' => 'post')) }} + {{Form::token()}} + + {{Form::bsText('title')}} + {{Form::bsTextArea('description')}} + + {{Form::submit('Submit', array('class'=>'btn btn-default'))}} + + {{ Form::close() }} +
+
+
+
+
+@endsection diff --git a/resources/views/syndie/contract/view.blade.php b/resources/views/syndie/contract/view.blade.php index c671065..7b430f1 100644 --- a/resources/views/syndie/contract/view.blade.php +++ b/resources/views/syndie/contract/view.blade.php @@ -64,13 +64,14 @@
+ @if(Auth::user()->user_id == $contract->contractee_id || Auth::user()->can('contract_moderate') ) + + + + + @endif
ID Reward: {{$contract->reward_other}}
Edit the Contract
- {{--
--}} - {{--

Contractee: {{$contract->contractee_name}}

--}} - {{--

Status: @include("components.syndiecontractstatus")

--}} - {{--

Reward: {{$contract->reward_other}}

--}} - {{--
--}}
@if(Auth::user()->cannot('contract_moderate'))
@else()
@endif() @@ -129,7 +130,8 @@

-

{!! nl2br(e($comment->comment)) !!}

+

@parsedown($comment->comment)

+ @if(Auth::user()->can('contract_moderate'))

Delete Comment

@endif
@@ -145,7 +147,8 @@

-

{!! nl2br(e($comment->comment)) !!}

+

@parsedown($comment->comment)

+ @if(Auth::user()->can('contract_moderate'))

Delete Comment

@endif
@@ -161,7 +164,8 @@

-

{!! nl2br(e($comment->comment)) !!}

+

@parsedown($comment->comment)

+ @if(Auth::user()->can('contract_moderate'))

Delete Comment

@endif
@@ -177,13 +181,14 @@

-

{!! nl2br(e($comment->comment)) !!}

+

@parsedown($comment->comment)

@if($contract->status == "completed" && (Auth::user()->user_id == $contract->contractee_id || Auth::user()->can('contract_moderate')))

Confirm Completion Reopen Contract

@endif() + @if(Auth::user()->can('contract_moderate'))

Delete Comment

@endif
@@ -199,7 +204,8 @@

-

{!! nl2br(e($comment->comment)) !!}

+

@parsedown($comment->comment)

+ @if(Auth::user()->can('contract_moderate'))

Delete Comment

@endif
@@ -215,7 +221,8 @@

-

{!! nl2br(e($comment->comment)) !!}

+

@parsedown($comment->comment)

+ @if(Auth::user()->can('contract_moderate'))

Delete Comment

@endif
@@ -231,7 +238,8 @@

-

{!! nl2br(e($comment->comment)) !!}

+

@parsedown($comment->comment)

+ @if(Auth::user()->can('contract_moderate'))

Delete Comment

@endif
@@ -248,17 +256,16 @@
New Message
-
- × - You can use Markdown to in the comment field -
- {{ Form::open(array('route' => array('syndie.contracts.addmessage',$contract->contract_id),'method' => 'post')) }} {{Form::token()}} {{--Only show the commentor name field of the user is not the owner of the contract or a mod--}} @if(Auth::user()->user_id != $contract->contractee_id || Auth::user()->can('contract_moderate')) +
+ × + The username is forced to your forum username for the following message types: 'ooc','mod-author','mod-ooc' +
{{Form::bsText('commentor_name')}} @else {{Form::hidden('commentor_name',$contract->contractee_name)}} @@ -271,7 +278,13 @@ @else(){{-- Otherwise --}} {{Form::bsSelectList('type',array('ic'=>'IC Comment','ic-failrep'=> 'IC Failure Report','ic-comprep'=>'IC Completion Report','ooc' => 'OOC Comment'))}} @endif() + {{Form::bsText('title')}} + +
+ × + You can use Markdown to in the comment field +
{{Form::bsTextArea('comment')}} {{Form::submit('Submit', array('class'=>'btn btn-default'))}}