Commit 14b1fcad authored by Antonio Amaddio's avatar Antonio Amaddio 🚀
Browse files

Final submission of code challenge

Exclusive user has been added. Redirect to admin login page has been put in place.
parent 4c1b7c07
......@@ -4,33 +4,26 @@ # Project Description
> "Please implement a dynamic web page that presents an overview of the research projects run at the Max-Planck-Institute for Human Development.
> A project should be addable through a simple survey mask. Required fields are project title, responsible researcher, department (ARC, LIP, CHM or HoE), data type (Online Survey, EEG, Behavioral, Simulation, MRI, Video, multiple options possible). An optional field might contain an identifier to a corresponding publication supported by Semantic Scholar (https://www.semanticscholar.org), e.g. DOI or ArXiv ID. A unique project ID is assigned to each project entered.
> All projects are displayed on a webpage in a tabular form. There is a filter based on data type and department. If an identifier to a publication is provided, the title of the publication is displayed along with the current number of citations the publications received (as provided by https://www.semanticscholar.org).
A project should be addable through a simple survey mask. Required fields are project title, responsible researcher, department (ARC, LIP, CHM or HoE), data type (Online Survey, EEG, Behavioral, Simulation, MRI, Video, multiple options possible). An optional field might contain an identifier to a corresponding publication supported by Semantic Scholar (https://www.semanticscholar.org), e.g. DOI or ArXiv ID. A unique project ID is assigned to each project entered.
> Optional: Prepare the project for deployment i.e. through dockerization.
> User management as well as editing of projects after submission, is not required. We expect the task to be solved within 6 hours maximum. Please organize your time accordingly and cut requirements as necessary.
> The solution can be programmed from scratch, an open-source solution can be adopted, or existing services can be composed.
All projects are displayed on a webpage in a tabular form. There is a filter based on data type and department. If an identifier to a publication is provided, the title of the publication is displayed along with the current number of citations the publications received (as provided by https://www.semanticscholar.org).
Optional: Prepare the project for deployment i.e. through dockerization.
User management as well as editing of projects after submission, is not required. We expect the task to be solved within 6 hours maximum. Please organize your time accordingly and cut requirements as necessary.
The solution can be programmed from scratch, an open-source solution can be adopted, or existing services can be composed.
Please provide us with the source code conveniently or showcase your solution in another suitable manner. Be prepared to present it during the interview in English or in German."
> Please provide us with the source code conveniently or showcase your solution in another suitable manner. Be prepared to present it during the interview in English or in German."
# Installation
- php artisan migrate:refresh --seed
- npm install && npn run dev
## Log in credentials
- user: doe@mpib-berlin.mpg.de
- password is: `password`
......@@ -105,8 +105,6 @@ public function store(StoreResearchProject $request)
public function show(ResearchProject $researchProject)
{
$this->authorize('admin.research-project.show', $researchProject);
// TODO your code goes here
}
/**
......
......@@ -2,41 +2,12 @@
namespace App\Http\Controllers;
use App\Http\Requests\Admin\ResearchProject\IndexResearchProject;
use App\Models\ResearchProject;
use Brackets\AdminListing\Facades\AdminListing;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
public function indexProjectOverview(IndexResearchProject $request){
// create and AdminListing instance for a specific model and
$data = AdminListing::create(ResearchProject::class)->processRequestAndGet(
// pass the request with params
$request,
// set columns to query
['id', 'project_title', 'responsible_researcher', 'department', 'data_type'],
// set columns to searchIn
['id', 'project_title', 'responsible_researcher', 'department', 'data_type', 'doi']
);
foreach($data->all() as $researchProject)
{
$researchProject->prepareDataTypeAttributeForIndex();
}
if ($request->ajax()) {
if ($request->has('bulk')) {
return [
'bulkItems' => $data->pluck('id')
];
}
return ['data' => $data];
}
return view('welcome', ['data' => $data]);
}
}
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use App\Http\Requests\Admin\ResearchProject\IndexResearchProject;
use App\Models\ResearchProject;
use Brackets\AdminListing\Facades\AdminListing;
use Illuminate\Http\Request;
class GuestController extends Controller
{
public function welcome(IndexResearchProject $request)
{
// create and AdminListing instance for a specific model and
$data = AdminListing::create(ResearchProject::class)->processRequestAndGet(
// pass the request with params
$request,
// set columns to query
['id', 'project_title', 'responsible_researcher', 'department', 'data_type'],
// set columns to searchIn
['id', 'project_title', 'responsible_researcher', 'department', 'data_type', 'doi']
);
foreach($data->all() as $researchProject)
{
$researchProject->prepareDataTypeAttributeForIndex();
}
if ($request->ajax()) {
if ($request->has('bulk')) {
return [
'bulkItems' => $data->pluck('id')
];
}
return ['data' => $data];
}
return view('welcome', ['data' => $data]);
}
}
......@@ -122,7 +122,27 @@ public function __construct()
//
],
],
[
'first_name' => 'john',
'last_name' => 'doe',
'email' => 'doe@mpib-berlin.mpg.de',
'password' => Hash::make('password'),
'remember_token' => null,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
'activated' => true,
'roles' => [
[
'name' => 'Administrator',
'guard_name' => $this->guardName,
],
],
'permissions' => [
//
],
],
];
}
/**
......
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AdminUserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('admin_users')->insert([
'email' => config('auth.admin_user_email'),
'password' => bcrypt(
config('auth.admin_user_password')
),
'first_name' => config('auth.admin_user_firstname'),
'last_name' => config('auth.admin_user_lastname'),
]);
}
}
......@@ -14,7 +14,6 @@ class DatabaseSeeder extends Seeder
public function run()
{
$this->call([
AdminUserSeeder::class,
DatatypeSeeder::class,
DepartmentSeeder::class,
]);
......
......@@ -13,8 +13,9 @@
|
*/
Route::get('/', 'App\Http\Controllers\GuestController@welcome');
Route::get('/', function () {
return redirect('/admin');
});
/* Auto-generated admin routes */
Route::middleware(['auth:' . config('admin-auth.defaults.guard'), 'admin'])->group(static function () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment