Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6609 ]Ks 2022 10 support btw phases #4638

Merged
merged 4 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions meinberlin/apps/budgeting/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,14 @@ def list(self, request, *args, **kwargs):
fetches the module
"""
permissions = {}

permissions['view_support_count'] = has_feature_active(
self.module, Proposal, 'support'
)
user = request.user
permissions['view_support_count'] = user.has_perm(
'meinberlin_budgeting.view_support', self.module)
permissions['view_rate_count'] = self.module.has_feature(
'rate', Proposal
)
permissions['view_comment_count'] = (
self.module.has_feature('comment', Proposal)
and not has_feature_active(self.module, Proposal, 'vote')
)

response = super().list(request, args, kwargs)
Expand Down
1 change: 1 addition & 0 deletions meinberlin/apps/budgeting/assets/SupportBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const SupportBox = (props) => {
<button
aria-label={translations.support}
className={`rating-button rating-up ${userSupported ? 'is-selected' : ''}`}
disabled={props.isReadOnly}
onClick={handleSupport}
>
<i className="far fa-thumbs-up" aria-hidden="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

{% block ratings %}
{% if module.blueprint_type == 'PB3' and proposal|has_feature:"support" %}
{% has_or_would_have_perm 'meinberlin_budgeting.support_proposal' request.user proposal as may_support_proposal %}
{% if may_support_proposal %}
{% has_or_would_have_perm 'meinberlin_budgeting.view_support' request.user module as may_view_support %}
{% if may_view_support %}
<div class="lr-bar__left">
{% react_support proposal %}
</div>
Expand Down
9 changes: 9 additions & 0 deletions meinberlin/apps/budgeting/templatetags/react_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.utils.html import format_html

from adhocracy4.ratings import models as rating_models
from adhocracy4.rules.discovery import NormalUser

register = template.Library()

Expand All @@ -29,13 +30,21 @@ def react_support(context, obj):
user_supported = bool(user_support.value)
user_support_id = user_support.pk

permission = '{ct.app_label}.support_{ct.model}'.format(ct=contenttype)
has_support_permission = user.has_perm(permission, obj)
would_have_support_permission = NormalUser().would_have_perm(
permission, obj
)

attributes = {
'contentType': contenttype.pk,
'objectId': obj.pk,
'authenticated': authenticated,
'support': obj.positive_rating_count,
'userSupported': user_supported,
'userSupportId': user_support_id,
'isReadOnly': (not has_support_permission and
not would_have_support_permission),
fuzzylogic2000 marked this conversation as resolved.
Show resolved Hide resolved
'style': 'ideas',
}

Expand Down