Skip to content

Commit

Permalink
Merge branch 'main' into FFT-125/scrollable-tables-2
Browse files Browse the repository at this point in the history
  • Loading branch information
CaitBarnard authored Jan 16, 2025
2 parents 7eee21a + 44f85bb commit 10e9f8c
Show file tree
Hide file tree
Showing 21 changed files with 408 additions and 226 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DJANGO_SETTINGS_MODULE=config.settings.local
DEBUGPY_ENABLED=False
SECRET_KEY=super-secret-key
ALLOWED_HOSTS="*"
DEBUG=True
Expand Down
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# This repo is maintained by the Employee Experience team
* @uktrade/employee-experience
# ... more specifically, the Sidewinders squad
* @uktrade/sidewinders
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,36 @@ The names of the management commands denote their function.
- Amend the custom_usermodel table to be the same as the new User app one
- Add the user app initial migration to the list of django migrations that have been run
- Deploy new codebase

# Setup DebugPy

Add environment variable in your .env file

```bash
ENABLE_DEBUGPY=True
```

Create launch.json file inside .vscode directory

```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "0.0.0.0",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app/"
}
]
}
]
}
```
18 changes: 18 additions & 0 deletions core/management/commands/runserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from django.core.management.commands.runserver import Command as RunserverCommand


class Command(RunserverCommand):
def run(self, *args, **options):
if os.getenv("DEBUGPY_ENABLED", "False").lower() == "true":
if os.getenv("RUN_MAIN") or os.getenv("WERKZEUG_RUN_MAIN"):
import debugpy

try:
debugpy.listen(("0.0.0.0", 5678))
self.stdout.write("debugpy: listening on port 5678...\n")
except Exception as err:
self.stderr.write(f"debugpy: failed to initialize {err}\n")

super().run(*args, **options)
23 changes: 23 additions & 0 deletions core/templatetags/util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from copy import copy
from typing import Iterator, TypedDict

from django import template

from forecast.models import FinancialPeriod


register = template.Library()

Expand All @@ -28,3 +31,23 @@ def instances_and_widgets(bound_field):
def has_end_of_month_archive_permissions(user):
if user.is_superuser or user.groups.filter(name="Finance Administrator"):
return True


class PreviousMonths(TypedDict):
month_short_name = str
month_financial_code = int


@register.simple_tag
def get_previous_months_data():
def generator_data() -> Iterator[PreviousMonths]:
qs = FinancialPeriod.objects.filter(actual_loaded=True).order_by(
"financial_period_code"
)
for obj in qs:
yield PreviousMonths(
month_short_name=obj.period_short_name,
month_financial_code=obj.financial_period_code,
)

return list(generator_data())
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ services:
command: python manage.py runserver 0.0.0.0:8000
# command: granian --interface wsgi config.wsgi:application --workers 2 --host 0.0.0.0 --port 8000
ports:
- "0.0.0.0:8000:8000"
- "8000:8000"
- "5678:5678"
volumes:
- ./:/app/
depends_on:
Expand Down
Loading

0 comments on commit 10e9f8c

Please sign in to comment.