#175 show TBD when a discussion link doesn't exist yet, show if user already voted
Merged 3 years ago by lbrabec. Opened 3 years ago by lbrabec.

@@ -237,6 +237,17 @@ 

      return (len(vote['+1']), len(vote['0']), len(vote['-1']))

  

  

+ def user_voted(bug_votes):

+     if not g.fas_user:

+         return False

+ 

+     voters = set()

+     for tracker_votes in bug_votes.values():

+         voters.update(itertools.chain(*tracker_votes.values()))

+ 

+     return g.fas_user.username in voters

+ 

+ 

  def web_voting_info(bugz, milestone):

      """Returns voting tuple for each bug and each section in web UI,

      a dict in dict structure in format:
@@ -258,7 +269,8 @@ 

              'Accepted Freeze Exceptions': vote_count_tuple(votes, f'{milestone}freezeexception'),

              'Accepted 0-day Blockers': vote_count_tuple(votes, '0day'),

              'Accepted Previous Release Blockers': vote_count_tuple(votes, 'previousrelease'),

-             'Prioritized Bugs': None  # no discussion for prioritized bugs

+             'Prioritized Bugs': None,  # no discussion for prioritized bugs

+             'user_voted': user_voted(votes),

          }

      return voting_info

  

@@ -84,7 +84,19 @@ 

                              <span class="{{'text-danger' if  vote_info[bug.bugid][buglist][2] > 0 else ''}}">-{{ vote_info[bug.bugid][buglist][2] }}</span>

                              <br />

                              {% endif %}

-                             <a href='{{ bug.discussion_link }}' target="_blank" rel="noopener noreferrer">{{ 'Discuss' if buglist.startswith('Accepted') else 'Vote!' }}</a>

+                             {% if bug.discussion_link %}

+                             <a href='{{ bug.discussion_link }}' target="_blank" rel="noopener noreferrer">

+                                 {% if buglist.startswith('Accepted') %}

+                                     Discuss

+                                 {% elif vote_info[bug.bugid]['user_voted'] %}

+                                     <span class="text-success">Voted</span>

+                                 {% else %}

+                                     Vote!

+                                 {% endif %}

+                             </a>

+                             {% else %}

+                             TBD

+                             {% endif %}

                          </td>

                          <td class="popupification">

                              <a href="{{ url_for('main.display_bug_updates', bugid=bug.bugid) }}"

Fix for #174

This PR includes a change proposed by @lruzicka: show if user already voted.

Build succeeded.

1 new commit added

  • use set instead of list
3 years ago

Build succeeded.

rebased onto 40dddd3

3 years ago

Commit 40dddd3 fixes this pull-request

Pull-Request has been merged by lbrabec

3 years ago

Pull-Request has been merged by lbrabec

3 years ago

Build succeeded.