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

akvo / iwsims-demo / #264

19 Jun 2025 06:53AM UTC coverage: 81.49% (-5.9%) from 87.348%
#264

push

coveralls-python

web-flow
Merge 4b62edd4b into 6ce6dff52

2265 of 2862 branches covered (79.14%)

Branch coverage included in aggregate %.

5294 of 6414 relevant lines covered (82.54%)

0.83 hits per line

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

87.23
backend/utils/functions.py
1
from django.utils import timezone
1✔
2
from api.v1.v1_data.models import Answers, AnswerHistory
1✔
3
from api.v1.v1_forms.constants import QuestionTypes
1✔
4

5

6
def update_date_time_format(date):
1✔
7
    if date:
1✔
8
        # date = timezone.datetime.strptime(date, "%Y-%m-%d").date()
9
        if not timezone.is_naive(date):
1!
10
            return timezone.localtime(date).strftime("%Y-%m-%d %I:%M %p")
×
11
        return date.strftime("%Y-%m-%d %I:%M %p")
1✔
12
    return None
1✔
13

14

15
def get_answer_value(answer: Answers):
1✔
16
    if answer.question.type in [
1✔
17
        QuestionTypes.geo,
18
        QuestionTypes.option,
19
        QuestionTypes.multiple_option,
20
    ]:
21
        return answer.options
1✔
22
    elif answer.question.type == QuestionTypes.number:
1✔
23
        return answer.value
1✔
24
    elif answer.question.type == QuestionTypes.administration:
1✔
25
        return int(float(answer.value)) if answer.value else None
1✔
26
    else:
27
        return answer.name
1✔
28

29

30
def get_answer_history(answer_history: AnswerHistory):
1✔
31
    value = None
1✔
32
    created = update_date_time_format(answer_history.created)
1✔
33
    created_by = answer_history.created_by.get_full_name()
1✔
34
    if answer_history.question.type in [
1✔
35
        QuestionTypes.geo,
36
        QuestionTypes.option,
37
        QuestionTypes.multiple_option,
38
    ]:
39
        value = answer_history.options
1✔
40
    elif answer_history.question.type == QuestionTypes.number:
1!
41
        value = answer_history.value
×
42
    elif answer_history.question.type == QuestionTypes.administration:
1!
43
        value = int(float(answer_history.value))
×
44
    else:
45
        value = answer_history.name
1✔
46
    return {"value": value, "created": created, "created_by": created_by}
1✔
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

© 2026 Coveralls, Inc