add workflow actions for manipulating server_state
This commit is contained in:
parent
b7b04a61d6
commit
c86c9fe9f4
14 changed files with 141 additions and 24 deletions
|
@ -20,6 +20,7 @@ use Illuminate\Support\Facades\Validator;
|
|||
use App\Models\DatasetReference;
|
||||
use App\Models\GeolocationBox;
|
||||
use App\Models\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
|
@ -277,7 +278,11 @@ class IndexController extends Controller
|
|||
$input = $request->except('files', 'licenses', 'abstract_main', 'title_main', 'references', 'titles');
|
||||
// array_push($input, "Himbeere");
|
||||
// $input += ['server_state' => 'created' ];
|
||||
$input['server_state'] = 'unpublished';
|
||||
if (isset($data['server_state'])) {
|
||||
$input['server_state'] = $data['server_state'];
|
||||
} else {
|
||||
$input['server_state'] = 'inprogress';
|
||||
}
|
||||
$dataset = new Dataset($input);
|
||||
|
||||
DB::beginTransaction(); //Start transaction!
|
||||
|
@ -397,6 +402,10 @@ class IndexController extends Controller
|
|||
$dataset->geolocation()->save($geolocation);
|
||||
}
|
||||
}
|
||||
|
||||
// Create relation between Dataset and actual User.
|
||||
$user = Auth::user();
|
||||
$dataset->user()->associate($user)->save();
|
||||
|
||||
// $error = 'Always throw this error';
|
||||
// throw new \Exception($error);
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
|
|||
// use Illuminate\Http\Request;
|
||||
use App\Models\Dataset;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class WorkflowController extends Controller
|
||||
{
|
||||
|
@ -21,14 +22,27 @@ class WorkflowController extends Controller
|
|||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
public function review()
|
||||
{
|
||||
$builder = Dataset::query();
|
||||
$datasets = $builder
|
||||
//->where('server_state', 'inprogress')
|
||||
->whereIn('server_state', ['unpublished'])
|
||||
->get();
|
||||
return view('workflow.index', compact('datasets'));
|
||||
return view('workflow.review', compact('datasets'));
|
||||
}
|
||||
|
||||
public function release()
|
||||
{
|
||||
$user = Auth::user();
|
||||
$user_id = $user->id;
|
||||
|
||||
$builder = Dataset::query();
|
||||
$datasets = $builder
|
||||
->where('server_state', 'inprogress')
|
||||
->where('account_id', $user_id)
|
||||
->get();
|
||||
return view('workflow.release', compact('datasets'));
|
||||
}
|
||||
|
||||
public function changestate($id, $targetState)
|
||||
|
@ -51,10 +65,11 @@ class WorkflowController extends Controller
|
|||
//$this->_sendNotification($document, $form);
|
||||
$time = new \Illuminate\Support\Carbon();
|
||||
$dataset->server_date_published = $time;
|
||||
session()->flash('flash_message', 'You have puplished 1 dataset!');
|
||||
}
|
||||
$dataset->save();
|
||||
session()->flash('flash_message', 'You have puplished 1 dataset!');
|
||||
return redirect()->route('settings.review.index');
|
||||
return redirect()->back();
|
||||
//return redirect()->route('settings.review.index');
|
||||
} catch (Exception $e) {
|
||||
//return $this->_redirectTo('index', array('failure' => $e->getMessage()), 'documents', 'admin');
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Models;
|
|||
use App\Library\Xml\DatasetExtension;
|
||||
use App\Models\Collection;
|
||||
use App\Models\License;
|
||||
use App\Models\User;
|
||||
use App\Models\Project;
|
||||
use App\Models\Description;
|
||||
use App\Models\Title;
|
||||
|
@ -78,6 +79,14 @@ class Dataset extends Model
|
|||
return $this->belongsTo(Project::class, 'project_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the account that the dataset belongs to
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'account_id', 'id');
|
||||
}
|
||||
|
||||
public function collections()
|
||||
{
|
||||
return $this
|
||||
|
|
|
@ -7,6 +7,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
|||
use Zizaco\Entrust\Traits\EntrustUserTrait;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Models\Dataset;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
|
@ -39,12 +40,19 @@ class User extends Authenticatable
|
|||
*/
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
|
||||
public function datasets()
|
||||
{
|
||||
//model, foreign key on the User model is account_id, local id of user
|
||||
return $this->hasMany(Dataset::class, 'account_id', 'id');
|
||||
}
|
||||
|
||||
public function setPasswordAttribute($password)
|
||||
{
|
||||
if ($password) {
|
||||
$this->attributes['password'] = app('hash')->needsRehash($password) ? Hash::make($password) : $password;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getAvatarUrl()
|
||||
{
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue