[ljcom] r11430: LJSUP-11188: No communities to promote u...
Committer: vtroitsky
LJSUP-11188: No communities to promote use case: more server-side error processing addedU trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm U trunk/htdocs/shop/selfpromo.bml.text.local
Modified: trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm 2012-02-08 11:52:11 UTC (rev 11429)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm 2012-02-08 12:46:37 UTC (rev 11430)
@@ -99,7 +99,7 @@
};
$elem->{'ljuser'} = $remote->ljuser_display() if $remote && $type eq 'journal';
- $elem->{'communities'} = [ map { {'user' => $_ } } LJ::get_authas_list($remote, {type => 'C'}) ] if $remote && $type eq 'community';
+ $elem->{'communities'} = [ map { {'user' => $_ } } grep { $_ ne $remote->{'user'} } LJ::get_authas_list($remote, {type => 'C'}) ] if $remote && $type eq 'community';
push @{$result->{$type}}, $elem;
}
return $result;
@@ -174,6 +174,11 @@
# TODO (refactoring):
my $object_url = LJ::Request->post_param('object_link');
+
+ unless ($object_url || $type eq 'journal') {
+ return $format_result->( 'error', LJ::Lang::ml('/shop/selfpromo.bml.error.'.$type.'.not_specified') );
+ }
+
unless ( $object_url =~ m{^https?://} || $type ne 'entry') {
$object_url = 'http://' . $object_url;
}
@@ -239,13 +244,17 @@
return $format_result->( 'success', $template->output );
}
-
# TODO: Need refactoring: Create promotion object from URLs (detect necessary), that call methods of that object Incapsulate all logic inside that object !!
sub process_promote_request {
my ($self, $type, $class) = @_;
my $remote = LJ::get_remote();
my $object_url = LJ::Request->post_param('object_link');
+
+ unless ($object_url || $type eq 'journal') {
+ $self->ml_error('/shop/selfpromo.bml.error.'.$type.'.not_specified');
+ }
+
unless ( $object_url =~ m{^https?://} || $type ne 'entry') {
$object_url = 'http://' . $object_url;
}
Modified: trunk/htdocs/shop/selfpromo.bml.text.local
===================================================================
--- trunk/htdocs/shop/selfpromo.bml.text.local 2012-02-08 11:52:11 UTC (rev 11429)
+++ trunk/htdocs/shop/selfpromo.bml.text.local 2012-02-08 12:46:37 UTC (rev 11430)
@@ -84,6 +84,10 @@
.error.not_logged_in=This action is not permitted for anonymous users.
+.error.entry.not_specified=No entry specified to promote.
+
+.error.community.not_specified=No community specified to promote.
+
.error.price_insufficient=[[price]] [[?price|LJ Token is|LJ Tokens are]] insufficient; you will need to pay at least [[need]] [[?need|LJ Token|LJ Tokens]].
.error.price_invalid=[[price]] [[?price|LJ Token|LJ Tokens]] is an invalid price; the price must be a multiple of 100.
