-
Notifications
You must be signed in to change notification settings - Fork 6
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
apps/budgeting/api: more info in API and serializer #4063
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
39995f0
apps/budgeting/api: add filter defaults
fuzzylogic2000 a031f5d
apps/budgeting/api: add static icon path only when categories have items
fuzzylogic2000 dbe32bf
apps/budgeting/api: rename FilterMixin and Pagination classes
fuzzylogic2000 26ec490
apps/budgeting/api: move locale info from serializer to API to only h…
fuzzylogic2000 4df2621
apps/budgeting/api: give all moderator feedback info in one field
fuzzylogic2000 408fd3f
gardening: make FIXME findable more easily
fuzzylogic2000 1909e3b
apps/budgeting/api: order newest first
fuzzylogic2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from django.utils import translation | ||
from rest_framework import serializers | ||
|
||
from adhocracy4.categories.models import Category | ||
|
@@ -26,19 +25,17 @@ class ProposalSerializer(serializers.ModelSerializer): | |
negative_rating_count = serializers.SerializerMethodField() | ||
category = CategoryField() | ||
url = serializers.SerializerMethodField() | ||
locale = serializers.SerializerMethodField() | ||
moderator_feedback = serializers.SerializerMethodField() | ||
|
||
class Meta: | ||
model = Proposal | ||
fields = ('budget', 'category', 'comment_count', 'created', 'modified', | ||
'creator', 'is_archived', 'name', 'negative_rating_count', | ||
'positive_rating_count', 'url', 'pk', 'moderator_feedback', | ||
'moderator_feedback_choices', 'locale') | ||
'positive_rating_count', 'url', 'pk', 'moderator_feedback') | ||
read_only_fields = ('budget', 'category', 'comment_count', 'created', | ||
'modified', 'creator', 'is_archived', 'name', | ||
'negative_rating_count', 'positive_rating_count', | ||
'url', 'pk', 'moderator_feedback', | ||
'moderator_feedback_choices', 'locale') | ||
'url', 'pk', 'moderator_feedback') | ||
|
||
def get_creator(self, proposal): | ||
return proposal.creator.username | ||
|
@@ -66,15 +63,7 @@ def get_url(self, proposal): | |
|
||
def get_moderator_feedback(self, proposal): | ||
if hasattr(proposal, 'moderator_feedback'): | ||
return proposal.moderator_feedback | ||
return (proposal.moderator_feedback, | ||
proposal.get_moderator_feedback_display()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better now :) |
||
else: | ||
return None | ||
|
||
def get_moderator_feedback_choices(self, proposal): | ||
if hasattr(proposal, 'moderator_feedback_choices'): | ||
return proposal.moderator_feedback_choices | ||
else: | ||
return None | ||
|
||
def get_locale(self, proposal): | ||
return translation.get_language() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice