wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r19139: LJSV-1569. Script did not assign some on...

Committer: gprochaev
LJSV-1569. Script did not assign some one maintainer communities an owner

U   trunk/htdocs/community/members.bml
U   trunk/htdocs/community/members.bml.text
Modified: trunk/htdocs/community/members.bml
===================================================================
--- trunk/htdocs/community/members.bml	2011-05-26 08:13:17 UTC (rev 19138)
+++ trunk/htdocs/community/members.bml	2011-05-26 08:37:19 UTC (rev 19139)
@@ -69,6 +69,38 @@
     my %attrshort = ( X => 'member', P => 'post', N => 'preapprove', M => 'moderate', A => 'admin');
     my %attrshort_r = ( map { $attrshort{$_} => $_ } keys %attrshort ); # reversed
 
+    if ($POST{'start_elections'}) {
+        return $print_with_ad->("<?h1 $ML{'Error'} h1?><?p $ML{'.error.poll_already_exists'} p?>")
+            if $c->prop("election_poll_id");
+
+        ## Check for maintainers alive
+        my $m_list = LJ::load_rel_user($c->userid, 'A');
+        my @maintainers = map {
+            my $u = LJ::load_userid($_);
+            $u;
+        } grep {
+            my $u = LJ::load_userid($_);
+            $u && $u->is_visible && !$u->is_expunged && $u->can_manage($c) ? 1 : 0;
+        } @$m_list;
+
+        return $print_with_ad->("<?h1 $ML{'Error'} h1?><?p $ML{'.error.no_maintainers'} p?>")
+            unless @maintainers;
+
+        my $log = '';
+        my $poll_id = LJ::create_supermaintainer_election_poll (
+                comm_id      => $c->userid, 
+                maint_list   => \@maintainers, 
+                log          => \$log,
+                no_job       => 0,
+                check_active => 1,
+        );
+
+        return $print_with_ad->("<?h1 $ML{'Error'} h1?><?p $ML{'.error.cant_create_poll'} p?>")
+            unless $poll_id;
+
+        $c->set_prop ('election_poll_id' => $poll_id);
+    }
+
     # saving a form submission
     if ($POST{'select_as_sm'}) {
         my $new_sm = $POST{'uid_to_sm'};
@@ -620,6 +652,19 @@
     $ret .= BML::ml('.intro', { aopts1 => "href='$LJ::HELPURL{maintainership}'", aopts2 => "href='$LJ::HELPURL{add_to_comm}'" }) . "<br /><br />";
     $ret .= $ML{'.intro.invite'};
 
+    $ret .= "<form method='post' action='members.bml?authas=$cname'>";
+    $ret .= LJ::form_auth();
+
+    ## Allow to start supermaintainer election via supermaintainer wish
+    my $super_maintainers = LJ::load_rel_user_cache($c->userid, 'S') || [];
+    my $poll_id = $c->prop('election_poll_id');
+    unless ($poll_id || scalar @$super_maintainers) {
+        $ret .= "<br/>" . LJ::Lang::ml('.you_can_start_election') . "&nbsp;";
+        $ret .= LJ::html_submit("start_elections", BML::ml('.start_elections'));
+    }
+
+    $ret .= "</form>";
+
     $ret .= "<form method='post' action='members.bml?authas=$cname' onsubmit='return confirm(\"" . BML::ml('.abdicate.supermaintainer') . "\")'>";
     $ret .= LJ::form_auth();
 
@@ -647,8 +692,6 @@
 
         $ret .= LJ::html_submit('select_as_sm', BML::ml('.set.user_to_supermaintainer')) . "<br/>";
     } else {
-        my $poll_id = $c->prop('election_poll_id');
-        my $super_maintainers = LJ::load_rel_user_cache($c->userid, 'S') || [];
         if ($poll_id && !scalar @$super_maintainers) {
             my $show_owner = 0;
             if ($poll_id) {

Modified: trunk/htdocs/community/members.bml.text
===================================================================
--- trunk/htdocs/community/members.bml.text	2011-05-26 08:13:17 UTC (rev 19138)
+++ trunk/htdocs/community/members.bml.text	2011-05-26 08:37:19 UTC (rev 19139)
@@ -18,6 +18,8 @@
 .error.maintainer|staleness=1
 .error.maintainer=Unable to revoke maintainer rights for [[user]].
 
+.error.no_maintainers=Community has not have maintainers
+
 .error.noaccess=Only community maintainers are able to edit membership lists. You are not a maintainer of community [[comm]].
 
 .error.noattr=No attributes selected for user: [[user]]
@@ -30,6 +32,10 @@
 
 .error.nouser=User does not exist: <b>[[user]]</b>
 
+.error.poll_already_exists=Election poll exists already
+
+.error.cant_create_poll=Can't create poll
+
 .error.unknown=Error inviting [[user]].  Please make sure they're not already a member and try again.
 
 .intro|staleness=1
@@ -67,6 +73,8 @@
 
 .set.user_to_supermaintainer=Proceed...
 
+.start_elections=Start election
+
 .success.added=added: [[list]]
 
 .success.deleted=removed: [[list]]
@@ -95,6 +103,8 @@
 
 .update=Update settings
 
+.you_can_start_election=You can start a election
+
 .you.supermaintainer=<br/><br/>Currently, you are <b>"SuperMaintainer"</b> for this community [[comm]].<br/><br/>You can abdicate and appoint another maintainer for this role:
 
 .abdicate.supermaintainer=Do you really want to do it?

Tags: bml, livejournal, text, wisest-owl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments