From: Tara L Andrews Date: Sun, 2 Sep 2012 21:36:52 +0000 (+0200) Subject: fix logic bugs in stexaminer with explicit stemma specification X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmaweb.git;a=commitdiff_plain;h=847e1ac6bbf676c2a7c9356918ba95f6e98cea60 fix logic bugs in stexaminer with explicit stemma specification --- diff --git a/lib/stemmaweb/Controller/Stexaminer.pm b/lib/stemmaweb/Controller/Stexaminer.pm index 36679ee..80d8827 100644 --- a/lib/stemmaweb/Controller/Stexaminer.pm +++ b/lib/stemmaweb/Controller/Stexaminer.pm @@ -37,7 +37,7 @@ sub index :Path :Args(2) { my $ok = _check_permission( $c, $tradition ); return unless $ok; if( $tradition->stemma_count ) { - my $stemma = $tradition->stemma(0); + my $stemma = $tradition->stemma( $stemid ); $c->stash->{svg} = $stemma->as_svg( { size => [ 600, 350 ] } ); $c->stash->{graphdot} = $stemma->editable({ linesep => ' ' }); $c->stash->{text_title} = $tradition->name; @@ -101,20 +101,16 @@ sub _check_permission { my( $c, $tradition ) = @_; my $user = $c->user_exists ? $c->user->get_object : undef; if( $user ) { - $c->stash->{'permission'} = 'full' - if( $user->is_admin || - ( $tradition->has_user && $tradition->user->id eq $user->id ) ); - return 1; - } - # Is it public? - if( $tradition->public ) { - $c->stash->{'permission'} = 'readonly'; - return 1; - } - # Forbidden! + return 'full' if ( $user->is_admin || + ( $tradition->has_user && $tradition->user->id eq $user->id ) ); + } + # Text doesn't belong to us, so maybe it's public? + return 'readonly' if $tradition->public; + + # ...nope. Forbidden! $c->response->status( 403 ); - $c->response->body( 'You do not have permission to view this tradition.' ); - $c->detach( 'View::Plain' ); + $c->response->body( 'You do not have permission to view this tradition' ); + $c->forward('View::Plain'); return 0; } diff --git a/root/js/stexaminer.js b/root/js/stexaminer.js index a6797e9..d64a3b6 100644 --- a/root/js/stexaminer.js +++ b/root/js/stexaminer.js @@ -5,12 +5,12 @@ var original_svg; function handle_row_click( row ) { var ridx = row.parent().parent().index() var rs = readingstats[ridx]; - var imghtml = 'Loading SVG...' + var imghtml = 'Loading SVG...' $('#stemma_graph').empty(); $('#stemma_graph').append( imghtml ); if( rs.layerwits ) { var stemma_form = { 'dot': graphdot, 'layerwits': rs.layerwits }; - $('#stemma_graph').load( 'graphsvg', stemma_form, function() { + $('#stemma_graph').load( '../graphsvg', stemma_form, function() { color_row( row ); show_stats( rs ); });