Skip to content

Commit

Permalink
Merge branch 'devel' of github.com:htgt/LIMS2-WebApp into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
sajp committed Sep 10, 2014
2 parents 4406679 + 186392a commit 0f976e4
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,9 @@
{{$NEXT}} {{$NEXT}}


0.238 2014-09-10 09:25:52 Europe/London

Added Project Efforts, under the Genes tab

0.237 2014-09-02 14:50:23 Europe/London 0.237 2014-09-02 14:50:23 Europe/London


Add interface to link crispr groups to designs Add interface to link crispr groups to designs
Expand Down
1 change: 1 addition & 0 deletions ddl/versions/72/audit-up.sql
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE audit.projects ADD COLUMN effort_concluded BOOLEAN NOT NULL DEFAULT FALSE;
1 change: 1 addition & 0 deletions ddl/versions/72/fixtures.sql
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO schema_versions(version) VALUES (72);
1 change: 1 addition & 0 deletions ddl/versions/72/up.sql
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE projects ADD COLUMN effort_concluded BOOLEAN NOT NULL DEFAULT FALSE;
67 changes: 67 additions & 0 deletions lib/LIMS2/Model/Plugin/Project.pm
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,67 @@
package LIMS2::Model::Plugin::Project;

use strict;
use warnings FATAL => 'all';

use Moose::Role;
use Hash::MoreUtils qw( slice slice_def );
use TryCatch;
use LIMS2::Exception;
use namespace::autoclean;

requires qw( schema check_params throw retrieve log trace );



sub pspec_retrieve_project {
return {
sponsor_id => { validate => 'non_empty_string' },
gene_id => { validate => 'non_empty_string' },
targeting_type => { validate => 'non_empty_string' },
species_id => { validate => 'existing_species' },
};
}

sub retrieve_project {
my ( $self, $params ) = @_;

my $validated_params = $self->check_params( $params, $self->pspec_retrieve_project );

my $project = $self->retrieve( Project => { slice_def $validated_params, qw( id sponsor_id gene_id targeting_type species_id ) } );

return $project;
}

sub pspec_retrieve_project_by_id {
return {
id => { validate => 'integer' },
};
}

sub retrieve_project_by_id {
my ( $self, $params ) = @_;

my $validated_params = $self->check_params( $params, $self->pspec_retrieve_project_by_id );

my $project = $self->retrieve( Project => { slice_def $validated_params, qw( id sponsor_id gene_id targeting_type species_id ) } );

return $project;
}

sub toggle_concluded_flag {
my ( $self, $params ) = @_;

my $project = $self->retrieve_project_by_id($params);

if ($project->effort_concluded) {
$project->update( { effort_concluded => 0 } );
} else {
$project->update( { effort_concluded => 1 } );
};

return $project;
}

1;

__END__
28 changes: 26 additions & 2 deletions lib/LIMS2/Model/Schema/Result/Project.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ __PACKAGE__->table("projects");
data_type: 'integer' data_type: 'integer'
is_nullable: 1 is_nullable: 1
=head2 effort_concluded
data_type: 'boolean'
default_value: false
is_nullable: 0
=cut =cut


__PACKAGE__->add_columns( __PACKAGE__->add_columns(
Expand All @@ -99,6 +105,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 }, { data_type => "text", is_nullable => 1 },
"htgt_project_id", "htgt_project_id",
{ data_type => "integer", is_nullable => 1 }, { data_type => "integer", is_nullable => 1 },
"effort_concluded",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
); );


=head1 PRIMARY KEY =head1 PRIMARY KEY
Expand Down Expand Up @@ -169,8 +177,24 @@ __PACKAGE__->belongs_to(
); );




# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-02-07 16:49:17 # Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-09-02 15:28:38
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NWx1GMZQcu6KlFq2s3dSaA # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E+p0emXyULopBYB1vFws9A


sub as_hash {
my $self = shift;

return {
"id" => $self->id,
"sponsor_id" => $self->sponsor_id,
"allele_request" => $self->allele_request,
"gene_id" => $self->gene_id,
"targeting_type" => $self->targeting_type,
"species_id" => $self->species_id,
"htgt_project_id" => $self->htgt_project_id,
"effort_concluded" => $self->effort_concluded,
}
}




# You can replace this text with custom code or comments, and it will be preserved on regeneration # You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
43 changes: 43 additions & 0 deletions lib/LIMS2/WebApp/Controller/API/Project.pm
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,43 @@
package LIMS2::WebApp::Controller::API::Project;
use Moose;
use Hash::MoreUtils qw( slice_def );
use namespace::autoclean;

BEGIN {extends 'LIMS2::Catalyst::Controller::REST'; }

sub project : Path( '/api/project' ) : Args(0) : ActionClass( 'REST' ) {
}

sub project_GET{
my ( $self, $c ) = @_;

$c->assert_user_roles('read');

my $project = $c->model( 'Golgi' )->txn_do(
sub {
shift->retrieve_project_by_id( { id => $c->request->param( 'id' ) } );
}
);

return $self->status_ok( $c, entity => $project->as_hash );
}

sub project_toggle : Path( '/api/project_toggle' ) : Args(0) : ActionClass( 'REST' ) {
}

sub project_toggle_GET{
my ( $self, $c ) = @_;

$c->assert_user_roles('read');

my $project = $c->model( 'Golgi' )->txn_do(
sub {
shift->toggle_concluded_flag( { id => $c->request->param( 'id' ) } );
}
);

return $self->status_ok( $c, entity => $project->as_hash );
}


1;
112 changes: 112 additions & 0 deletions lib/LIMS2/WebApp/Controller/User/Projects.pm
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,112 @@
package LIMS2::WebApp::Controller::User::Projects;
use Moose;
use LIMS2::WebApp::Pageset;
use namespace::autoclean;

BEGIN {extends 'Catalyst::Controller'; }

=head1 NAME
LIMS2::WebApp::Controller::User::Projects - Catalyst Controller
=head1 DESCRIPTION
Catalyst Controller.
=head1 METHODS
=cut


=head2 index
=cut

sub index :Path( '/user/projects' ) :Args(0) {
my ( $self, $c ) = @_;

$c->assert_user_roles('read');

my $params = $c->request->params;

my $species_id = $c->session->{selected_species};

my @sponsors_rs = $c->model('Golgi')->schema->resultset('Project')->search( {
species_id => $species_id
},{
columns => [ qw/sponsor_id/ ],
distinct => 1
}
);

my @sponsors = map { $_->sponsor_id } @sponsors_rs;

my $columns = ['id', 'gene_id', 'gene_symbol', 'sponsor', 'targeting type', 'concluded?'];

my $sel_sponsor;

$c->stash(
sponsor_id => [ map { $_->sponsor_id } @sponsors_rs ],
effort_concluded => ['true', 'false'],
title => 'Project Efforts',
columns => $columns,
sel_sponsor => $sel_sponsor,
);


return unless ( $params->{filter} || $params->{show_all} );

if ($params->{show_all}) {
$params->{sponsor_id} = '';
}

my $search = {
species_id => $species_id,
};

if ($params->{sponsor_id}) {
$search->{sponsor_id} = $params->{sponsor_id};
$sel_sponsor = $params->{sponsor_id};
}

my @projects_rs = $c->model('Golgi')->schema->resultset('Project')->search( $search );


my @project_genes = map { [
$_->id,
$_->gene_id,
$c->model('Golgi')->find_gene( { species => $species_id, search_term => $_->gene_id } )->{gene_symbol},
$_->sponsor_id,
$_->targeting_type,
$_->effort_concluded
] } @projects_rs;


$c->stash(
sponsor_id => [ map { $_->sponsor_id } @sponsors_rs ],
effort_concluded => ['true', 'false'],
title => 'Project Efforts',
columns => $columns,
data => \@project_genes,
get_grid => 1,
sel_sponsor => $sel_sponsor,
);

return;
}


=head1 AUTHOR
Team 87
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

__PACKAGE__->meta->make_immutable;

1;
3 changes: 3 additions & 0 deletions root/lib/navigation.tt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<li> <li>
<a href="[% c.uri_for( '/user/sponsor_report' ) %]">Sponsor Report</a> <a href="[% c.uri_for( '/user/sponsor_report' ) %]">Sponsor Report</a>
</li> </li>
<li>
<a href="[% c.uri_for( '/user/projects' ) %]">Project Efforts</a>
</li>
</ul> </ul>
</li> </li>


Expand Down
60 changes: 60 additions & 0 deletions root/site/user/projects/index.tt
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,60 @@

<div class="page-header">
<h1>[% title %]</h1>
</div>

<form method="GET" action="[% c.uri_for( '/user/projects' ) %]" class="well">
<fieldset>
<label for="sponsor_id">Sponsor:</label>
<select name="sponsor_id">
<option[% IF ! selected_sponsor.defined %] selected="selected" [% END %]>[% sel_sponsor %]</option>
[%- FOR sponsor IN sponsor_id %]
<option[% IF sponsor == selected_sponsor %] selected="selected"[% END %]>[% sponsor %]</option>
[%- END %]
</select>
<button name="filter" id="filter" type="submit" value="Filter" class="btn btn-primary"><i class="icon-filter icon-white"></i>Filter</button>
<button name="show_all" id="show_all" type="submit" value="Show All" class="btn"><i class="icon-list-alt"></i>Show All</button>
</fieldset>
<span class="help-block">
You can browse for efforts and mark them as concluded by checking the box.
</span>
</form>




<div id="my_results"></div>


[%- MACRO linkify(v) BLOCK %]
[%- IF v.match( '^https?:' ) %]
<a href="[% v %]">Test result</a>
[%- ELSIF v.match( '^custom:' ) %]
[%- USE String%]
[%- v_copy = String.new( text => v ) %]
[%- CALL v_copy.shift('custom:') %]
[%- FOREACH pair_val IN v_copy.split(';') %]
[%- pair_string = String.new ( text => pair_val) %]
[%- vals = pair_string.split('=', 2) %]
[%- left = vals.shift %]
[%- right = vals.shift %]
[%- custom.$left = right %]
[%- END %]
[%- button_label = custom.button_label %]
[%- tab_target = custom.browser_target %]
[%- api_url = custom.api_url %]
[%- custom.delete( 'button_label', 'api_url') -%]
<a class="btn btn-info btn-small" <a href="[% c.uri_for( api_url, custom ) %]" target="[% tab_target %]">[% button_label %]</a>
[%- ELSE %]
[%- v %]
[%- END %]
[%- END %]

<link rel="stylesheet" type="text/css" href="[% c.uri_for('/static/extjs/resources/css/ext-all.css') %]" />
<link rel="stylesheet" type="text/css" href="[% c.uri_for('/static/css/lims2_extjs.css') %]" />

<script type="text/javascript" src="[% c.uri_for('/static/extjs/ext-all.js') %]"></script>

[%- IF get_grid %]
[% PROCESS 'user/report/generic_report_grid.tt' %]
[%- END %]
Loading

0 comments on commit 0f976e4

Please sign in to comment.