user.html.tmpl 5.67 KB
Newer Older
1 2 3
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
  #
5 6
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
7 8
  #%]

9 10 11 12 13 14 15
[%# INTERFACE:
  # voting_user: hash containing a 'login' field
  #
  # products: list of hashes containing details of products relating to
  #           voting: 
  #            name: name of product
  #            bugs: list of bugs the user has voted for
16
  #            bug_ids: list of bug ids the user has voted for
17 18 19 20 21
  #            onevoteonly: one or more votes allowed per bug?
  #            total: users current vote count for the product
  #            maxvotes: max votes allowed for a user in this product
  #            maxperbug: max votes per bug allowed for a user in this product
  #
22
  # this_bug: Bugzilla::Bug; if the user is voting for a bug, this is the bug
23 24
  #
  # canedit: boolean; Should the votes be presented in a form, or readonly? 
25 26
  #
  # all_bug_ids: List of all bug ids the user has voted for, across all products
27 28
  #%]

29
[% IF !header_done %]
30
  [% subheader = voting_user.login FILTER html %]
31 32
  [% IF canedit %]
    [% title = "Change Votes" %]
33
    [% IF this_bug %]
34 35
      [%# We .select and .focus the input so it works for textbox and 
          checkbox %]
36 37
      [% onload = "document.forms['voting_form'].bug_" _ this_bug.id _
                  ".select();document.forms['voting_form'].bug_" _ this_bug.id _
38 39
                  ".focus()" %]
    [% END %]
40 41 42
  [% ELSE %]
    [% title = "Show Votes" %]
  [% END %]
43
  [% PROCESS global/header.html.tmpl
44
             style_urls = [ "extensions/Voting/web/style.css" ] 
45
  %]
46 47 48
[% ELSE %]
  <hr>
[% END %]
49 50

[% IF products.size %]
51
  <form name="voting_form" method="post" action="page.cgi?id=voting/user.html">
52
    <input type="hidden" name="action" value="vote">
53
    <input type="hidden" name="token" value="[% issue_hash_token(['vote']) FILTER html %]">
54
    <table id="user_votes">
55
      <tr>
56
        <th></th>
57
        <th>Votes</th>
58
        <th>[% terms.Bug %]&nbsp;#</th>
59 60 61
        <th>Summary</th>
      </tr>

62 63
      [% onevoteproduct = 0 %]
      [% multivoteproduct = 0 %]
64
      [% FOREACH product = products %]
65 66 67 68 69
        [% IF product.onevoteonly %]
          [% onevoteproduct = 1 %]
        [% ELSE %]
          [% multivoteproduct = 1 %]
        [% END %]
70 71
        <tr>
          <th>[% product.name FILTER html %]</th>
72
          <td colspan="2" ><a href="buglist.cgi?bug_id=
73
              [%- product.bug_ids.join(",") FILTER uri %]">([% terms.bug %] list)</a>
74 75
          </td>
          <td>
76 77
            [% IF product.maxperbug < product.maxvotes AND
                  product.maxperbug > 1 %]
78
              <font size="-1">
79
                (Note: only [% product.maxperbug FILTER html %] vote
80
                [% "s" IF product.maxperbug != 1 %] allowed per [% terms.bug %] in
81 82
                this product.)
              </font>
83 84
            [% END %]
          </td>
85 86 87
        </tr>

        [% FOREACH bug = product.bugs %]
88
          <tr [% IF bug.id == this_bug.id && canedit %] class="bz_bug_being_voted_on"[% END %]>
89 90 91 92 93 94 95 96 97
            <td>
              [% IF bug.id == this_bug.id && canedit %]
                [% IF product.onevoteonly %]
                  Vote For This [% terms.Bug %] &rarr;
                [% ELSE %]
                  Enter Votes Here &rarr;
                [% END %]
              [%- END %]
            </td>
98 99
            <td>
              <a name="vote_[% bug.id FILTER none %]">
100
              [% IF canedit %]
101
                [% IF product.onevoteonly %]
102 103
                  <input type="checkbox" name="[% bug.id FILTER none %]" value="1"
                    [% " checked" IF bug.count %] id="bug_[% bug.id FILTER none %]">
104
                [% ELSE %]
105 106
                  <input name="[% bug.id FILTER none %]" value="[% bug.count FILTER html %]"
                         size="2" id="bug_[% bug.id FILTER none %]">
107 108
                [% END %]
              [% ELSE %]
109
                [% bug.count FILTER html %]
110
              [% END %]
111 112 113
              </a>
            </td>
            <td class="right">
114
              [% PROCESS bug/link.html.tmpl bug = bug, link_text = bug.id %]
115 116
            </td>
            <td>
117 118
              [% bug.short_desc FILTER html %]
              (<a href="page.cgi?id=voting/bug.html&amp;bug_id=[% bug.id FILTER none %]">Show Votes</a>)
119
            </td>
120 121 122 123 124
          </tr>
        [% END %]

        <tr>
          <td></td>
125 126
          <td colspan="3">[% product.total FILTER html %] vote
            [% "s" IF product.total != 1 %] used out of [% product.maxvotes FILTER html %]
127 128 129 130 131 132 133 134
            allowed.
            <br>
            <br>
          </td>
        </tr>
      [% END %]
    </table>

135
    [% IF canedit %]
136
      <input type="submit" value="Change My Votes" id="change"> or 
137
      <a href="buglist.cgi?bug_id=[% all_bug_ids.join(",") FILTER uri %]">view all
138
        as [% terms.bug %] list</a>
139 140
      <br>
      <br>
141 142 143 144 145 146 147 148 149
      To change your votes,
      [% IF multivoteproduct %]
        type in new numbers (using zero to mean no votes)
        [% " or " IF onevoteproduct %]
      [% END %]
      [% IF onevoteproduct %]
        change the checkbox
      [% END %]
      and then click <b>Change My Votes</b>.
150
    [% ELSE %]
151
       <a href="buglist.cgi?bug_id=[% all_bug_ids.join(",") FILTER uri %]">View all
152
         as [% terms.bug %] list</a>
153
    [% END %]
154 155 156
  </form>
[% ELSE %]
  <p>
157
    [% IF canedit %]
158 159 160 161
    You are
    [% ELSE %]
    This user is
    [% END %]
162
    currently not voting on any [% terms.bugs %].
163 164 165 166
  </p>
[% END %]

<p>
167
  <a href="page.cgi?id=voting.html">Help with voting</a>.
168 169
</p>

170
[% PROCESS global/footer.html.tmpl %]