Skip to content

Commit

Permalink
Merge pull request #6 from Amsterdam/improvement/add-id-to-serializer…
Browse files Browse the repository at this point in the history
…-create-case

Added styling pre-commit
  • Loading branch information
NvdLaan authored Aug 5, 2024
2 parents 4123139 + e0c51ea commit 9002a6f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,20 @@ python manage.py migrate

name_of_apps is the model you would like to change like: cases, events, workflow or schedules.
You can use the `---empty` flag to create a custom migration.

## Adding pre-commit hooks

You can add pre-commit hooks for checking and cleaning up your changes:

```bash
bash bin/install_pre_commit.sh
```


## Running tests

Containers should be running to run tests via docker.

```bash
docker compose exec -T zwd-backend python manage.py test /app/apps
```
1 change: 1 addition & 0 deletions app/apps/cases/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@admin.register(Case)
class CaseAdmin(admin.ModelAdmin):
list_display = ("id", "description")
search_fields = ("id",)
3 changes: 3 additions & 0 deletions app/apps/cases/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
class Case(models.Model):
description = models.TextField(null=True)

def __str__(self):
return f"Case: {self.id}"


class CaseStateType(models.Model):
name = models.CharField(max_length=255, unique=True)
Expand Down
2 changes: 1 addition & 1 deletion app/apps/cases/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class Meta:
class CaseCreateSerializer(serializers.ModelSerializer):
class Meta:
model = Case
fields = ("description", "id")
fields = ("id", "description")
14 changes: 13 additions & 1 deletion app/apps/workflow/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@

@admin.register(CaseWorkflow)
class CaseWorkflowAdmin(admin.ModelAdmin):
list_display = ("id", "case")
list_display = (
"id",
"case",
"main_workflow",
"workflow_type",
"workflow_version",
"case_state_type",
"completed",
)

search_fields = ("case__id",)

list_filter = ("main_workflow", "completed")


@admin.register(CaseUserTask)
Expand Down
3 changes: 3 additions & 0 deletions app/apps/workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class CaseWorkflow(models.Model):
default=False,
)

def __str__(self):
return f"W: {self.id}, C: {self.case.id}"

def start(self):
workflow = self._get_or_restore_workflow_state()
initial_data = get_initial_data_from_config(
Expand Down
2 changes: 2 additions & 0 deletions app/apps/workflow/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re

from apps.cases.models import Case
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers
from rest_framework.fields import empty

Expand Down Expand Up @@ -41,6 +42,7 @@ class Meta:
"tasks",
)

@extend_schema_field(CaseUserTaskSerializer(many=True))
def get_tasks(self, obj):
return CaseUserTaskSerializer(
CaseUserTask.objects.filter(
Expand Down

0 comments on commit 9002a6f

Please sign in to comment.