Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
sajp committed Sep 11, 2012
2 parents 2eb2a11 + 6b1ac7a commit f7db4c4
Show file tree
Hide file tree
Showing 25 changed files with 3,920 additions and 1,473 deletions.
4 changes: 2 additions & 2 deletions ddl/templates/versions/10/up.sql
Expand Up @@ -4,7 +4,7 @@ CREATE TABLE cell_lines (
);
GRANT SELECT ON cell_lines TO "[% ro_role %]";
GRANT SELECT, INSERT, UPDATE, DELETE ON cell_lines TO "[% rw_role %]";

GRANT USAGE ON cell_lines_id_seq TO "[% rw_role %]";

INSERT INTO cell_lines (name)
SELECT DISTINCT cell_line
Expand All @@ -28,4 +28,4 @@ ALTER TABLE process_cell_line
DROP COLUMN cell_line;

ALTER TABLE audit.process_cell_line
DROP COLUMN cell_line;
DROP COLUMN cell_line;
10 changes: 5 additions & 5 deletions lib/LIMS2/Model/FormValidator/Constraint.pm
Expand Up @@ -203,11 +203,6 @@ sub existing_design_oligo_type {
return in_resultset( $model, 'DesignOligoType', 'id' );
}

#sub existing_pipeline {
# my ( $class, $model ) = @_;
# return in_resultset( $model, 'Pipeline', 'name' );
#}

sub existing_plate_type {
my ( $class, $model ) = @_;
return in_resultset( $model, 'PlateType', 'id' );
Expand Down Expand Up @@ -398,6 +393,11 @@ sub pass_or_fail {
return regexp_matches(qr/^(pass|fail)$/i);
}

# at least 6 non whitespace characters long
sub password_string {
return regexp_matches(qr/^\S{6,}$/);
}

1;

__END__
2 changes: 1 addition & 1 deletion lib/LIMS2/Model/Plugin/BAC.pm
Expand Up @@ -27,7 +27,7 @@ sub _chr_id_for {
return $chr->id;
}

sub pspec_list_bac_libraies {
sub pspec_list_bac_libraries {
return {
species => { validate => 'existing_species', rename => 'species_id' }
}
Expand Down
11 changes: 7 additions & 4 deletions lib/LIMS2/Model/Plugin/Design.pm
Expand Up @@ -169,18 +169,21 @@ sub delete_design {

# Check that design is not assigned to a gene
if ( $design->genes_rs->count > 0 ) {
$self->throw( InvalidState => 'Design ' . $design->design_id . ' has been assigned to one or more genes' );
$self->throw( InvalidState => 'Design ' . $design->id . ' has been assigned to one or more genes' );
}

# # Check that design is not allocated to a process and, if it is, refuse to delete
if ( $design->process_designs_rs->count > 0 ) {
$self->throw( InvalidState => 'Design ' . $design->design_id . ' has been used in one or more processes' );
$self->throw( InvalidState => 'Design ' . $design->id . ' has been used in one or more processes' );
}

if ( $validated_params->{cascade} ) {
$design->comments_rs->delete;
$design->oligos_rs->delete;
$design->genotyping_primers_rs->delete;
for my $oligo ( $design->oligos_rs->all ) {
$oligo->loci_rs->delete;
$oligo->delete;
}
}

$design->delete;
Expand Down Expand Up @@ -280,7 +283,7 @@ sub _get_gene_chr_start_end_strand {
$self->throw(
NotFound => {
message => 'Found no matching EnsEMBL genes',
entity => 'EnsEMBL Gene',
entity_class => 'EnsEMBL Gene',
search_params => { external_id => $gene_id }
}
);
Expand Down
2 changes: 1 addition & 1 deletion lib/LIMS2/Model/Plugin/Process.pm
Expand Up @@ -60,7 +60,7 @@ sub delete_process {

$process->delete;

return;
return 1;
}

sub list_process_types {
Expand Down
26 changes: 26 additions & 0 deletions lib/LIMS2/Model/Plugin/User.pm
Expand Up @@ -244,6 +244,32 @@ sub set_user_preferences {
return $prefs;
}

sub pspec_change_user_password {
return {
id => { validate => 'integer' },
new_password => { validate => 'password_string' },
new_password_confirm => { validate => 'password_string' },
};
}

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

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

$self->throw( Validation => 'new password and password confirm values do not match' )
unless $validated_params->{new_password} eq $validated_params->{new_password_confirm};

my $user = $self->retrieve( User => { id => $validated_params->{id} } );

my $csh = Crypt::SaltedHash->new( algorithm => "SHA-1" );
$csh->add( $validated_params->{new_password} );

$user->update( { password => $csh->generate } );

return $user;
}

1;

__END__
88 changes: 88 additions & 0 deletions lib/LIMS2/WebApp/Controller/User/UserPreferences.pm
@@ -0,0 +1,88 @@
package LIMS2::WebApp::Controller::User::UserPreferences;
use Moose;
use namespace::autoclean;
use Try::Tiny;

BEGIN {extends 'Catalyst::Controller'; }

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

# Need to have edit writes to make any changes in db, including password
# so users with only the read role can not change their password at the moment
# TODO: see if there is a way to get around this if its worth doing
sub begin :Private {
my ( $self, $c ) = @_;

$c->assert_user_roles( 'edit' );
return;
}

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

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

return unless $params->{change_password};

unless ( $params->{new_password} ) {
$c->stash->{error_msg} = 'You must specify a new password';
return;
}

unless ( $params->{new_password_confirm} ) {
$c->stash->{error_msg} = 'You must fill in password confirm box as well';
return;
}

unless ( $params->{new_password_confirm} eq $params->{new_password} ) {
$c->stash->{error_msg} = 'new password and password confirm values do not match';
return;
}

$c->model('Golgi')->txn_do(
sub {
try{
my $user = $c->model('Golgi')->change_user_password(
{ id => $c->user->id,
new_password => $params->{new_password},
new_password_confirm => $params->{new_password_confirm}
}
);

$c->flash->{success_msg} = 'Password successfully changed for: ' . $user->name ;
$c->res->redirect( $c->uri_for('/') );
}
catch {
$c->stash->{error_msg} = 'Error encountered while changing password : ' . $_;
$c->model('Golgi')->txn_rollback;
};
}
);

return;
}

=head1 AUTHOR
Sajith Perera
=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;
76 changes: 50 additions & 26 deletions root/lib/navigation.tt
@@ -1,15 +1,17 @@
<div class="navbar navbar-fixed-top">
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="[% c.uri_for( '/' ) %]">HTGT LIMS2</a>
[% IF template.title != 'Login' %]
<ul class="nav">

<li[% IF template.tab_name == "Home" %] class="active"[% END %]>
<a href="[% c.uri_for( '/' ) %]">Home</a>
</li>


<li class="dropdown[% IF template.tab_name == "Browse" %] active[% END %]">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Browse<b class="caret"></b></a>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Browse <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="[% c.uri_for( '/user/browse_designs' ) %]">Designs</a>
Expand All @@ -26,8 +28,9 @@
</ul>
</li>


<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Reports<b class="caret"></b></a>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Reports <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="[% c.uri_for( '/user/report/gene' ) %]">
Expand Down Expand Up @@ -63,62 +66,83 @@
</li>

<li class="dropdown[% IF template.tab_name == "Plates" %] active[% END %]">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Plates<b class="caret"></b></a>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Plates <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="[% c.uri_for( '/user/browse_plates' ) %]">Browse</a>
</li>
[% IF c.check_user_roles( 'edit' ) %]
<li>
<a href="[% c.uri_for( '/user/plate_upload_step1' ) %]">Upload</a>
</li>
[% END %]
</ul>
</li>

<li class="dropdown[% IF template.tab_name == "QC" %] active[% END %]">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">QC<b class="caret"></b></a>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">QC <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="[% c.uri_for( '/user/qc_runs' ) %]">Browse Sequencing QC</a>
</li>
[% IF c.check_user_roles( 'edit' ) %]
<li>
<a href="[% c.uri_for( '/user/dna_status_update' ) %]">Update DNA Status</a>
</li>
[% END %]
</ul>
</li>

[% IF c.check_user_roles( 'admin' ) %]
<li[% IF template.tab_name == "Admin" %] class="active"[% END %]>
<a href="[% c.uri_for( '/admin' ) %]">Admin</a>
</li>
[% END %]

[% IF c.session.selected_species %]
<li class="dropdown pull-right">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">[% c.session.selected_species %]<b class="caret"></b></a>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
[% c.session.selected_species %] <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>&nbsp Switch species:</li>
[%- FOR species_id IN c.session.species %]
[%- IF species_id != c.session.selected_species %]
<li>
<a href="[% c.uri_for( '/user/select_species', { species => species_id } ) %]">
[% species_id %]
</a>
</li>
[% END %]
[% END %]
</ul>
</li>
[% END %]

</ul>

[% IF c.user %]

<ul class="nav pull-right">
<li class="divider-vertical"></li>
<li class="dropdown[% IF template.tab_name == "User" %] active[% END %]">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">[% c.user.name %] <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Switch species:</li>
[%- FOR species_id IN c.session.species %]
[%- IF species_id != c.session.selected_species %]
<li>
<a href="[% c.uri_for( '/user/select_species', { species => species_id } ) %]">
[% species_id %]
</a>
</li>
[% IF c.check_user_roles( 'admin' ) %]
<li><a href="[% c.uri_for( '/admin' ) %]"><i class="icon-user"></i> User Admin</a></li>
[% END %]
[% END %]
[% IF c.check_user_roles( 'edit' ) %]
<li><a href="[% c.uri_for('/user/change_password') %]"><i class="icon-pencil"></i> Change Password</a></li>
<li class="divider"></li>
[% END %]
<li><a href="[% c.uri_for('/logout') %]"><i class="icon-off"></i> Logout</a></li>
</ul>
</li>
[% END %]
</ul>

[% ELSE %]

<p class="nav pull-right">
[% IF c.user %]
Logged in as [% c.user.name %] <a class="btn" href="[% c.uri_for('/logout') %]">Logout</a>
[% ELSE %]
<a class="btn" href="[% c.uri_for('/login') %]">Login</a>
[% END %]
</p>

[% END %]

</div>
[% END %]
</div>
Expand Down
14 changes: 11 additions & 3 deletions root/lib/wrapper.tt
Expand Up @@ -61,10 +61,18 @@
</div>
[% END %]
[% content | none %]
<footer>
LIMS2 software version: [% c.model('Golgi').software_version %], database: [% c.model('Golgi').database_name %].
</footer>
</div> <!-- /container -->

<div class="navbar navbar-fixed-bottom">
<div class="navbar-inner">
<div class="container">
<p class="nav pull-right navbar-text">
version: <strong>[% c.model('Golgi').software_version %]</strong> |
database: <strong>[% c.model('Golgi').database_name %]</strong>
</p>
</div>
</div>
</div>

</body>
</html>
1 change: 0 additions & 1 deletion root/site/user/browseplates/index.tt
Expand Up @@ -23,7 +23,6 @@
<thead>
<tr>
<th>Plate Name</th>
<th></th>
<th>Plate Type</th>
<th>Description</th>
<th>Created By</th>
Expand Down

0 comments on commit f7db4c4

Please sign in to comment.