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

apps//settings: add votes app with models #3978

Merged
merged 1 commit into from
Nov 19, 2021

Conversation

Rineee
Copy link
Contributor

@Rineee Rineee commented Nov 19, 2021

To test you first need a 3 phase bürgerhaushalt. You can add a token in django-admin for this module.

The TokenVote cannot be added in django-admin due to the generic foreign key. So you need to do that in the django-shell.

from meinberlin.apps.votes.models import VotingToken, TokenVote
from meinberlin.apps.budgeting.models import Proposal
token = VotingToken.objects.get(token='myTokenFromDjangoAdmin')
module = token.module
proposal = Proposal.objects.filter(module=module).first()
vote = TokenVote(token = token, content_object=proposal)
vote.save()

@github-actions
Copy link

Coverage report

Total coverage

Status Category Percentage Covered / Total
🔴 Statements 0.91% 11/1204
🔴 Branches 0.57% 4/696
🔴 Functions 1.27% 5/393
🔴 Lines 2.27% 78/3436

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

Report generated by 🧪jest coverage report action from c906457

Copy link
Contributor

@fuzzylogic2000 fuzzylogic2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So cool!
I think we can merge?!

Module,
on_delete=models.CASCADE
)
allowed_votes = models.PositiveSmallIntegerField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should go to the module? But we can also change it later/if need be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, that should probably eventually go to the module. I just didnt really dare to add it to all modules in A4 😬 But lets keep that in mind once we think about the generating of the tokens?

return TokenVote.objects.filter(token=self)

@property
def num_votes_left(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, this is cool! So, maybe we also just keep the allowed_votes here. Even though, we will also need them in the module to set them here... We could then get this property from the module instead. But anyway, that is not that important now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could then just do return self.module.allowed_votes - num_votes here

@fuzzylogic2000 fuzzylogic2000 merged commit 810e770 into main Nov 19, 2021
@fuzzylogic2000 fuzzylogic2000 deleted the ks-2021-11-add-vote-app branch November 19, 2021 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants