add workflow actions for manipulating server_state
This commit is contained in:
parent
b7b04a61d6
commit
c86c9fe9f4
|
@ -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!
|
||||
|
@ -398,6 +403,10 @@ class IndexController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// 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,6 +40,12 @@ 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) {
|
||||
|
@ -46,6 +53,7 @@ class User extends Authenticatable
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function getAvatarUrl()
|
||||
{
|
||||
return "https://www.gravatar.com/avatar/" . md5($this->email) . "?d=mm";
|
||||
|
|
12
composer.lock
generated
12
composer.lock
generated
|
@ -3566,16 +3566,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpunit/php-timer",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
||||
"reference": "8b8454ea6958c3dee38453d3bd571e023108c91f"
|
||||
"reference": "8b389aebe1b8b0578430bda0c7c95a829608e059"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f",
|
||||
"reference": "8b8454ea6958c3dee38453d3bd571e023108c91f",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b389aebe1b8b0578430bda0c7c95a829608e059",
|
||||
"reference": "8b389aebe1b8b0578430bda0c7c95a829608e059",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3587,7 +3587,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0-dev"
|
||||
"dev-master": "2.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -3611,7 +3611,7 @@
|
|||
"keywords": [
|
||||
"timer"
|
||||
],
|
||||
"time": "2018-02-01T13:07:23+00:00"
|
||||
"time": "2019-02-20T10:12:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-token-stream",
|
||||
|
|
|
@ -15,7 +15,7 @@ class CreateDocumentsTable extends Migration
|
|||
Schema::create('documents', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('type', 100);
|
||||
$table->string('publication_state', 100)->default('draft');;
|
||||
$table->string('publication_state', 100)->default('draft');
|
||||
$table->boolean('belongs_to_bibliography')->default('0');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -337,9 +337,22 @@
|
|||
<xsl:apply-templates select="@Language" mode="oai_dc" />
|
||||
<!-- dc:rights -->
|
||||
<xsl:apply-templates select="Licence" mode="oai_dc" />
|
||||
<!-- dc:coverage -->
|
||||
<xsl:apply-templates select="GeolocationBox" mode="oai_dc" />
|
||||
</oai_dc:dc>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="GeolocationBox" mode="oai_dc">
|
||||
<dc:coverage>
|
||||
<xsl:value-of select="concat(
|
||||
'SOUTH-BOUND LATITUDE: ', @Xmin,
|
||||
' * WEST-BOUND LONGITUDE: ', @Ymin,
|
||||
' * NORTH-BOUND LATITUDE: ', @Xmax,
|
||||
' * EAST-BOUND LONGITUDE: ', @Ymax
|
||||
)" />
|
||||
</dc:coverage>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="TitleMain" mode="oai_dc">
|
||||
<dc:title>
|
||||
<xsl:value-of select="@Value"/>
|
||||
|
|
|
@ -152,7 +152,7 @@ const app = new Vue({
|
|||
this.currentStatus = STATUS_INITIAL;
|
||||
this.dataset.files = [];
|
||||
},
|
||||
save() {
|
||||
save(status) {
|
||||
// upload data to the server
|
||||
var _this = this;
|
||||
this.currentStatus = STATUS_SAVING;
|
||||
|
@ -177,6 +177,7 @@ const app = new Vue({
|
|||
/*
|
||||
Additional POST Data
|
||||
*/
|
||||
formData.append('server_state', status);
|
||||
formData.append('type', this.dataset.type);
|
||||
// formData.append('server_state', this.dataset.state);
|
||||
formData.append('rights', Number(this.dataset.rights));
|
||||
|
@ -395,10 +396,10 @@ const app = new Vue({
|
|||
}
|
||||
return true;
|
||||
},
|
||||
submit() {
|
||||
submit(status) {
|
||||
// alert('Submit to blah and show blah and etc.');
|
||||
// save it
|
||||
this.save();
|
||||
this.save(status);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -487,9 +487,13 @@
|
|||
<i class="fa fa-arrow-left"></i>
|
||||
<span>Zurück</span>
|
||||
</button>
|
||||
<button @click.prevent="submit()" class="pure-button button-small">
|
||||
<button @click.prevent="submit('inprogress')" class="pure-button button-small">
|
||||
<i class="fa fa-save"></i>
|
||||
<span>Create Dataset</span>
|
||||
<span>Save Dataset</span>
|
||||
</button>
|
||||
<button @click.prevent="submit('unpublished')" class="pure-button button-small">
|
||||
<i class="fa fa-upload"></i>
|
||||
<span>Release Dataset</span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -95,8 +95,11 @@
|
|||
<li class="pure-menu-item {{ Route::is('publish.dataset.create') ? 'active' : '' }}">
|
||||
<a class="pure-menu-link" href="{{ URL::route('publish.dataset.create') }}"><i class="fa fa-upload"></i> Create</a>
|
||||
</li>
|
||||
<li class="pure-menu-item {{ Route::is('settings.review') ? 'active' : '' }}">
|
||||
<a class="pure-menu-link" href="{{ URL::route('settings.review.index') }}"><i class="fa fa-upload"></i> Release unpublished datasets</a>
|
||||
<li class="pure-menu-item {{ Route::is('settings.workflow.release') ? 'active' : '' }}">
|
||||
<a class="pure-menu-link" href="{{ URL::route('settings.workflow.release') }}"><i class="fa fa-upload"></i> Release pending datasets</a>
|
||||
</li>
|
||||
<li class="pure-menu-item {{ Route::is('settings.workflow.review') ? 'active' : '' }}">
|
||||
<a class="pure-menu-link" href="{{ URL::route('settings.workflow.review') }}"><i class="fa fa-upload"></i> Review/Publish unpublished datasets</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
51
resources/views/workflow/release.blade.php
Normal file
51
resources/views/workflow/release.blade.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
@extends('settings.layouts.app')
|
||||
@section('content')
|
||||
<div class="header">
|
||||
<h3 class="header-title">
|
||||
<i class="fa fa-file"></i> Release saved datasets
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="pure-g box-content">
|
||||
<div class="pure-u-1">
|
||||
<table class="pure-table pure-table-horizontal">
|
||||
|
||||
<thead>
|
||||
<th>Dataset Title</th>
|
||||
<th>ID</th>
|
||||
<th>Server State</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach($datasets as $dataset)
|
||||
<tr>
|
||||
<td>
|
||||
@if ($dataset->titles()->first())
|
||||
{{ $dataset->titles()->first()->value }}
|
||||
@else
|
||||
no title
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
{{ $dataset->id }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $dataset->server_state }}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@if ($dataset->server_state == "inprogress")
|
||||
<a href="{{ URL::route('settings.review.changestate',['id' => $dataset->id, 'targetState' => 'unpublished']) }}" class="pure-button button-small is-success">Release</a>
|
||||
{{-- <a href="" class="pure-button button-small is-success">Restrict</a> --}}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
|
@ -2,7 +2,7 @@
|
|||
@section('content')
|
||||
<div class="header">
|
||||
<h3 class="header-title">
|
||||
<i class="fa fa-file"></i> Datasets to be processed
|
||||
<i class="fa fa-file"></i> Review unpblished datasets
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
|||
<th>Dataset Title</th>
|
||||
<th>ID</th>
|
||||
<th>Server State</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
|
@ -120,10 +120,13 @@ Route::group(
|
|||
// //For DataTables
|
||||
Route::get('pages/get', ['uses' => 'PagesTableController@get'])->name('page.get');
|
||||
|
||||
Route::get('review', [
|
||||
'as' => 'review.index', 'uses' => 'WorkflowController@index',
|
||||
Route::get('workflow/review', [
|
||||
'as' => 'workflow.review', 'uses' => 'WorkflowController@review',
|
||||
]);
|
||||
Route::get('review/changestate/{id}/changestate/{targetState}', [
|
||||
Route::get('workflow/release', [
|
||||
'as' => 'workflow.release', 'uses' => 'WorkflowController@release',
|
||||
]);
|
||||
Route::get('workflow/changestate/{id}/changestate/{targetState}', [
|
||||
'as' => 'review.changestate', 'uses' => 'WorkflowController@changestate',
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user