# Path: server/daprojects_webapp/maps.py
# def get_map_for_project(project):
#     # TODO 1: create a model for project visualization options, and let the user choose the map.
#     return _maps[(project.id - 1) % len(_maps)]


from django.views.generic.base import TemplateView
from django.shortcuts import get_object_or_404
from daprojects_core import models
from .maps import get_map_for_project




class HomeView(TemplateView):
    template_name = 'daprojects_webapp/home.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['projects_and_maps'] = [
            (project, get_map_for_project(project)) for project in models.Project.objects.all()
        ]
        return context


class ProjectView(TemplateView):
    template_name = 'daprojects_webapp/project.html'

    def get_context_data(self, project_id=None, **kwargs):
        context = super().get_context_data(**kwargs)
        project = get_object_or_404(models.Project, pk=project_id)

# Path: server/daprojects_webapp/maps.py
# def get_map_for_project(project):
#     # TODO 1: create a model for project visualization options, and let the user choose the map.
#     return _maps[(project.id - 1) % len(_maps)]


# Path: server/daprojects_webapp/views.py
from django.views.generic.base import TemplateView
from django.shortcuts import get_object_or_404
from daprojects_core import models
from .maps import get_map_for_project





class HomeView(TemplateView):
    template_name = 'daprojects_webapp/home.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['projects_and_maps'] = [
            (project, get_map_for_project(project)) for project in models.Project.objects.all()
        ]
        return context


class ProjectView(TemplateView):
    template_name = 'daprojects_webapp/project.html'

    def get_context_data(self, project_id=None, **kwargs):
        context = super().get_context_data(**kwargs)
        project = get_object_or_404(models.Project, pk=project_id)

        map = get_map_for_project(project)