Commit 45bb6868 authored by Keith Jolley's avatar Keith Jolley
Browse files

A 'submitter' can only add an isolate with themselves as sender.

parent d73923f0
......@@ -66,6 +66,7 @@ sub _check {
my $loci = $self->{'datastore'}->get_loci( { query_pref => 1, set_id => $set_id } );
my $metadata_list = $self->{'datastore'}->get_set_metadata( $set_id, { curate => 1 } );
my $field_list = $self->{'xmlHandler'}->get_field_list($metadata_list);
my $user_info = $self->{'datastore'}->get_user_info_from_username($self->{'username'});
@$loci = uniq @$loci;
my @bad_field_buffer;
my $insert = 1;
......@@ -79,6 +80,8 @@ sub _check {
if ( $required_field == $required ) {
if ( $field eq 'curator' ) {
$newdata->{$field} = $self->get_curator_id;
} elsif ($field eq 'sender' && $user_info->{'status'} eq 'submitter'){
$newdata->{$field} = $self->get_curator_id;
} elsif ( $field eq 'datestamp' || $field eq 'date_entered' ) {
$newdata->{$field} = $self->get_datestamp;
} else {
......@@ -260,6 +263,8 @@ sub print_provenance_form_elements {
my ( $self, $newdata, $options ) = @_;
$options = {} if ref $options ne 'HASH';
my $q = $self->{'cgi'};
#TODO Limit sender list if user status is 'submitter'.
my $user_info = $self->{'datastore'}->get_user_info_from_username($self->{'username'});
my ( @users, %usernames );
my $user_data =
$self->{'datastore'}
......@@ -346,6 +351,8 @@ sub print_provenance_form_elements {
}
} elsif ( lc($field) eq 'curator' ) {
say "<b>" . $self->get_curator_name . ' (' . $self->{'username'} . ")</b>";
} elsif (lc($field) eq 'sender' && $user_info->{'status'} eq 'submitter' && !$options->{'update'}){
say "<b>" . $self->get_curator_name . ' (' . $self->{'username'} . ")</b>";
} elsif ( lc($field) eq 'sender' || lc($field) eq 'sequenced_by' || ( $thisfield->{'userfield'} // '' ) eq 'yes' ) {
say $q->popup_menu(
-name => $field,
......
......@@ -114,15 +114,17 @@ sub _get_form_fields {
$options = {} if ref $options ne 'HASH';
my $q = $self->{'cgi'};
my %newdata = %{$newdata_ref};
my $sql = $self->{'db'}->prepare("select id,user_name,first_name,surname from users where id>0 order by surname");
eval { $sql->execute };
$logger->error($@) if $@;
my @users;
my %usernames;
$usernames{''} = ' '; #Required for HTML5 validation
local $" = ' ';
my $user_data =
$self->{'datastore'}
->run_query( "SELECT id,user_name,first_name,surname FROM users WHERE id>0 ORDER BY surname", undef, { fetch => 'all_arrayref' } );
while ( my ( $user_id, $username, $firstname, $surname ) = $sql->fetchrow_array ) {
foreach my $user_data (@$user_data) {
my ( $user_id, $username, $firstname, $surname ) = @$user_data;
push @users, $user_id;
$usernames{$user_id} = "$surname, $firstname ($username)";
}
......
Supports Markdown
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