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

akvo / iwsims-demo / #93

30 Apr 2025 07:36AM UTC coverage: 86.373% (+0.07%) from 86.3%
#93

Pull #29

coveralls-python

ifirmawan
[#28] Remove any county, sub-County terms in the backend
Pull Request #29: Feature/28 eng 1232 data submission by admin super admin

2591 of 3118 branches covered (83.1%)

Branch coverage included in aggregate %.

5915 of 6730 relevant lines covered (87.89%)

0.88 hits per line

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

93.1
backend/api/v1/v1_data/management/commands/generate_config.py
1
import json
1✔
2

3
from django.core.management import BaseCommand
1✔
4
from jsmin import jsmin
1✔
5

6
from iwsims.settings import COUNTRY_NAME
1✔
7
from api.v1.v1_forms.models import Forms
1✔
8
from api.v1.v1_profile.models import Levels
1✔
9
from api.v1.v1_forms.serializers import FormDataSerializer
1✔
10

11

12
class Command(BaseCommand):
1✔
13
    def handle(self, *args, **options):
1✔
14
        print("GENERATING CONFIG JS")
1✔
15
        topojson = open(f"source/{COUNTRY_NAME}.topojson").read()
1✔
16

17
        # write config
18
        config_file = jsmin(open("source/config/config.js").read())
1✔
19
        levels = []
1✔
20
        forms = []
1✔
21
        for level in Levels.objects.all():
1✔
22
            levels.append(
1✔
23
                {
24
                    "id": level.id,
25
                    "name": level.name,
26
                    "level": level.level,
27
                }
28
            )
29
        for form in Forms.objects.all():
1!
30
            forms.append(
×
31
                {
32
                    "id": form.id,
33
                    "name": form.name,
34
                    "version": form.version,
35
                    "content": FormDataSerializer(instance=form).data,
36
                }
37
            )
38
        min_config = jsmin(
1✔
39
            "".join(
40
                [
41
                    "var topojson=",
42
                    topojson,
43
                    ";",
44
                    "var levels=",
45
                    json.dumps(levels),
46
                    ";",
47
                    "var forms=",
48
                    json.dumps(forms),
49
                    ";",
50
                    config_file,
51
                ]
52
            )
53
        )
54
        open("source/config/config.min.js", "w").write(min_config)
1✔
55
        # os.remove(administration_json)
56
        del levels
1✔
57
        del forms
1✔
58
        del min_config
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

© 2025 Coveralls, Inc