seedlot upload with accession synonyms. seedlot upload works to update existing seedlots
[sgn.git] / lib / SGN / Controller / People.pm
blob1e6f04cf9ae9f04fd1ab4a64cf85a61a12264f59
2 package SGN::Controller::People;
4 use Moose;
5 use CXGN::Login;
6 use CXGN::People::Person;
7 use Data::Dumper;
8 use CXGN::Phenome::Population;
9 use SGN::Controller::solGS::AnalysisProfile;
10 use CXGN::Page::FormattingHelpers qw/info_section_html page_title_html info_table_html simple_selectbox_html html_optional_show columnar_table_html/;
11 use CXGN::Phenome::Locus;
13 BEGIN { extends 'Catalyst::Controller' };
15 sub people_search : Path('/search/people') Args(0) {
16 my $self = shift;
17 my $c = shift;
18 $c->stash->{template} = '/search/people.mas';
23 #Code migrated from /cgi-bin/solpeople/top-level.pl
24 sub people_top_level : Path('/solpeople/profile') Args(1) {
25 my $self = shift;
26 my $c = shift;
27 my $person_id = shift;
28 my $dbh = $c->dbc->dbh;
30 #will redirect user to login page if they are not logged in.
31 my $user_id=CXGN::Login->new($dbh)->verify_session();
32 if (!$user_id) {
33 $c->res->redirect('/solpeople/login.pl');
34 $c->detach();
36 my $users_profile;
37 if ($person_id == $user_id) {
38 $users_profile = 1;
40 my @roles = $c->user->get_roles;
41 my %roles_hash;
42 foreach (@roles) {
43 $roles_hash{$_} = 1;
46 my $p = CXGN::People::Person->new($dbh, $person_id);
47 my $user_type = $p->get_user_type;
49 if ($users_profile) {
51 # User's populations sections
52 my @pops = CXGN::Phenome::Population->my_populations($person_id);
53 my $pops_list;
54 foreach my $pop (@pops) {
55 my $pop_name = $pop->get_name();
56 my $pop_id = $pop->get_population_id();
57 my $is_public = $pop->get_privacy_status();
58 if ($is_public) { $is_public = 'is publicly available'; }
59 if ( !$is_public ) { $is_public = 'is not publicly available yet'; }
60 $pops_list .= qq |<a href="/qtl/population/$pop_id">$pop_name</a> <i>($is_public)</i><br/>|;
62 if (!$pops_list) {
63 $pops_list = '<h4>You have no populations.</h4>';
65 $c->stash->{populations_list} = $pops_list;
67 ##SOLGS user's submitted jobs sections
68 my $solgs_jobs = SGN::Controller::solGS::AnalysisProfile->solgs_analysis_status_log($c);
69 my $solgs_jobs_table;
70 if(@$solgs_jobs) {
71 $solgs_jobs_table = columnar_table_html(
72 headings => [ 'Analysis name', 'Submitted on', 'Status', 'Result page'],
73 data => $solgs_jobs,
74 __alt_freq => 2,
75 __align => 'llll',
77 } else {
78 $solgs_jobs_table = '<h4>You have no submitted jobs.</h4>';
80 $c->stash->{solgs_jobs_list} = $solgs_jobs_table;
82 #User Loci section
83 my @loci = CXGN::Phenome::Locus::get_locus_ids_by_editor( $dbh, $person_id );
84 my $top = 50;
85 my $more = 0;
86 my $max = @loci;
87 if ( @loci > 24 ) {
88 $more = @loci - 24;
89 $max = 24;
91 my $locus_editor_info = "<h4>You have no loci to edit.</h4>";
92 if ( @loci > 0 ) {
93 $locus_editor_info = "";
95 for ( my $i = 0 ; $i < ($max) ; $i++ ) {
96 my $locus = CXGN::Phenome::Locus->new( $dbh, $loci[$i] );
97 my $symbol = $locus->get_locus_symbol();
98 my $locus_id = $locus->get_locus_id();
99 $locus_editor_info .= qq { <a href="/phenome/locus_display.pl?locus_id=$locus_id&amp;action=view">$symbol</a> };
101 if ($more) {
102 $locus_editor_info .= qq|<br><b>and <a href="/search/locus/>$more more</a></b><br />|;
104 $c->stash->{loci_editor_privileges} = $locus_editor_info;
106 my @annotated_loci = CXGN::Phenome::Locus::get_locus_ids_by_annotator( $dbh, $person_id );
107 $more = 0;
108 $max = @annotated_loci;
109 if ( @annotated_loci > 24 ) {
110 $more = @annotated_loci - 24;
111 $max = 24;
113 my ( $locus_annotations, $more_annotations );
114 for ( my $i = 0 ; $i < $top ; $i++ ) {
115 my $locus = CXGN::Phenome::Locus->new( $dbh, $annotated_loci[$i] );
116 my $symbol = $locus->get_locus_symbol() ? $locus->get_locus_symbol() : '';
117 my $locus_id = $locus->get_locus_id() ? $locus->get_locus_id() : '';
119 if ( $i < $max ) {
120 $locus_annotations .= qq | <a href="/locus/$locus_id/view">$symbol</a> |;
121 } else {
122 $more_annotations .= qq { <a href="/locus/$locus_id/view">$symbol</a> };
125 if ($more) {
126 $locus_annotations .= " and $more more, not shown.<br />";
128 $locus_annotations .= html_optional_show( 'locus_annotations', 'Show more', qq|<div class="minorbox">$more_annotations</div> | );
130 $locus_annotations .= qq| <a href="../phenome/recent_annotated_loci.pl">[View annotated loci by date]</a> |;
131 $c->stash->{loci_annotations} = $locus_annotations;
133 #User status section
134 my $user_info = {
135 user => qq{ Your current user status is <b>$user_type</b>. Please contact <a href="mailto:sgn-feedback\@sgn.cornell.edu">SGN</a> to upgrade to a <b>submitter</b> account with more privileges. Submitters can upload user maps, EST data, and become locus editors. },
136 submitter => qq{ Your current user status is <b>$user_type</b>. You have the maximum user privileges on SGN. Please contact <a href="mailto:sgn-feedback\@sgn.cornell.edu">SGN</a> if you would like to change your user status.},
137 curator => qq{ Your current user status is <b>$user_type</b>. },
138 sequencer => qq{ Your current user status is <b>$user_type</b>. You have maximum user privileges on SGN. },
139 genefamily_editor => qq{ Your current user status is <b>$user_type</b>. },
141 $c->stash->{user_status} = $user_info->{$user_type};
144 $c->stash->{site_name} = $c->config->{project_name};
145 $c->stash->{user_roles} = \%roles_hash;
146 $c->stash->{sp_person_id} = $p->get_sp_person_id;
147 $c->stash->{username} = $c->user->get_object->get_username;
148 $c->stash->{first_name} = $p->get_first_name;
149 $c->stash->{last_name} = $p->get_last_name;
150 $c->stash->{is_users_profile} = $users_profile;
151 $c->stash->{template} = '/people/profile.mas';