• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

liqd / adhocracy-plus / 18908688697

29 Oct 2025 12:59PM UTC coverage: 44.622% (-44.5%) from 89.135%
18908688697

Pull #2986

github

web-flow
Merge 1dfde8ee7 into 445e1d498
Pull Request #2986: Draft: Speed up Github Ci Tests

3012 of 6750 relevant lines covered (44.62%)

0.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/interactiveevents/serializers.py
1
from rest_framework import serializers
×
2

3
from adhocracy4.categories.models import Category
×
4
from adhocracy4.modules.models import Module
×
5

6
from .models import Like
×
7
from .models import LiveQuestion
×
8

9

10
class LiveQuestionSerializer(serializers.ModelSerializer):
×
11
    category = serializers.StringRelatedField()
×
12
    likes = serializers.SerializerMethodField()
×
13

14
    class Meta:
×
15
        model = LiveQuestion
×
16
        exclude = ("module", "created", "modified")
×
17

18
    def get_likes(self, livequestion):
×
19
        session = self.context["request"].session.session_key
×
20
        session_like = bool(
×
21
            livequestion.livequestion_likes.filter(session=session).first()
22
        )
23
        if hasattr(livequestion, "like_count"):
×
24
            like_count = livequestion.like_count
×
25
        else:
26
            like_count = 0
×
27
        result = {"count": like_count, "session_like": session_like}
×
28
        return result
×
29

30
    def create(self, validated_data):
×
31
        module_pk = self.context["view"].module_pk
×
32
        module = Module.objects.get(pk=module_pk)
×
33
        category_pk = self.context["view"].kwargs["category"]
×
34
        if category_pk:
×
35
            category = Category.objects.get(pk=category_pk)
×
36
            validated_data["category"] = category
×
37
        validated_data["module"] = module
×
38
        livequestion = super().create(validated_data)
×
39

40
        return livequestion
×
41

42

43
class LikeSerializer(serializers.ModelSerializer):
×
44
    class Meta:
×
45
        model = Like
×
46
        fields = ("id",)
×
47

48
    def create(self, validated_data):
×
49
        return Like.objects.get_or_create(**validated_data)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc