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

Problematy / goodmap / 18472638744

13 Oct 2025 04:46PM UTC coverage: 98.862% (+0.02%) from 98.845%
18472638744

Pull #261

github

web-flow
Merge 2cdd2053a into b08abd867
Pull Request #261: feat: new way of setting up frontend version

515 of 528 branches covered (97.54%)

Branch coverage included in aggregate %.

24 of 25 new or added lines in 2 files covered. (96.0%)

1049 of 1054 relevant lines covered (99.53%)

1.0 hits per line

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

84.78
/goodmap/goodmap.py
1
import os
1✔
2

3
from flask import Blueprint, redirect, render_template, session
1✔
4
from flask_wtf.csrf import CSRFProtect, generate_csrf
1✔
5
from platzky import platzky
1✔
6
from platzky.config import languages_dict
1✔
7
from platzky.models import CmsModule
1✔
8

9
from goodmap.config import GoodmapConfig
1✔
10
from goodmap.core_api import core_pages
1✔
11
from goodmap.data_models.location import create_location_model
1✔
12
from goodmap.db import extend_db_with_goodmap_queries, get_location_obligatory_fields
1✔
13

14

15
def create_app(config_path: str) -> platzky.Engine:
1✔
16
    config = GoodmapConfig.parse_yaml(config_path)
1✔
17
    return create_app_from_config(config)
1✔
18

19

20
# TODO Checking if there is a feature flag secition should be part of configs logic not client app
21
def is_feature_enabled(config: GoodmapConfig, feature: str) -> bool:
1✔
22
    return config.feature_flags.get(feature, False) if config.feature_flags else False
1✔
23

24

25
def create_app_from_config(config: GoodmapConfig) -> platzky.Engine:
1✔
26
    directory = os.path.dirname(os.path.realpath(__file__))
1✔
27

28
    locale_dir = os.path.join(directory, "locale")
1✔
29
    config.translation_directories.append(locale_dir)
1✔
30
    app = platzky.create_app_from_config(config)
1✔
31

32
    if is_feature_enabled(config, "USE_LAZY_LOADING"):
1✔
33
        location_obligatory_fields = get_location_obligatory_fields(app.db)
1✔
34
    else:
35
        location_obligatory_fields = []
1✔
36

37
    location_model = create_location_model(location_obligatory_fields)
1✔
38

39
    app.db = extend_db_with_goodmap_queries(app.db, location_model)
1✔
40

41
    CSRFProtect(app)
1✔
42

43
    cp = core_pages(
1✔
44
        app.db,
45
        languages_dict(config.languages),
46
        app.notify,
47
        generate_csrf,
48
        location_model,
49
        feature_flags=config.feature_flags,
50
    )
51
    app.register_blueprint(cp)
1✔
52
    goodmap = Blueprint("goodmap", __name__, url_prefix="/", template_folder="templates")
1✔
53

54
    @goodmap.route("/")
1✔
55
    def index():
1✔
NEW
56
        return render_template(
×
57
            "map.html",
58
            feature_flags=config.feature_flags,
59
            goodmap_frontend_lib_url=config.goodmap_frontend_lib_url,
60
        )
61

62
    @goodmap.route("/goodmap-admin")
1✔
63
    def admin():
1✔
64
        user = session.get("user", None)
×
65
        if not user:
×
66
            return redirect("/admin")
×
67

68
        # TODO: This should be replaced with a proper user authentication check,
69
        #       cms_modules should be passed from the app
70
        return render_template(
×
71
            "goodmap-admin.html",
72
            feature_flags=config.feature_flags,
73
            goodmap_frontend_lib_url=config.goodmap_frontend_lib_url,
74
            user=user,
75
            cms_modules=app.cms_modules,
76
        )
77

78
    app.register_blueprint(goodmap)
1✔
79
    goodmap_cms_modules = CmsModule.model_validate(
1✔
80
        {
81
            "name": "Map admin panel",
82
            "description": "Admin panel for managing map data",
83
            "slug": "goodmap-admin",
84
            "template": "goodmap-admin.html",
85
        }
86
    )
87
    app.add_cms_module(goodmap_cms_modules)
1✔
88

89
    return app
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