Skip to content

Commit

Permalink
Merge pull request #682 from Amsterdam/azure
Browse files Browse the repository at this point in the history
Azure
  • Loading branch information
NvdLaan authored Jun 6, 2024
2 parents 4db42c1 + 5aa911f commit 0ce83ce
Show file tree
Hide file tree
Showing 30 changed files with 580 additions and 269 deletions.
20 changes: 7 additions & 13 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@
DJANGO_SETTINGS_MODULE=settings.settings
DJANGO_SECRET_KEY=local
DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=0.0.0.0,localhost,api
DJANGO_ALLOWED_HOSTS=0.0.0.0,localhost,api,*
CORS_ORIGIN_WHITELIST=http://0.0.0.0:3000,http://localhost:3000,http://0.0.0.0:2999,http://localhost:2999
DATABASE_NAME=looplijsten
DATABASE_USER=looplijsten
DATABASE_NAME=top
DATABASE_USER=top
DATABASE_PASSWORD=insecure
DATABASE_HOST=database
SENTRY_DSN=https://[email protected]/0
LOCAL_DEVELOPMENT_AUTHENTICATION=True
LOCAL_DEVELOPMENT_AUTHENTICATION=False
LOCAL_DEVELOPMENT_USE_MULTIPROCESSING=True
ZAKEN_API_URL=http://zaak-gateway:8000/api/v1
ZAKEN_API_HEALTH_URL=http://zaak-gateway:8000/health
PUSH_ZAKEN=False # Disabled for local development, enable to test Zaken connection
UWSGI_HTTP=0.0.0.0:8000
SECRET_KEY_TOP_ZAKEN=SECRET_KEY_TOP_ZAKEN
RABBIT_MQ_USERNAME=guest
RABBIT_MQ_PASSWORD=guest
RABBIT_MQ_URL=rabbitmq
RABBIT_MQ_PORT=5672

# RabbitMQ settings
RABBITMQ_DEFAULT_USER=guest
RABBITMQ_DEFAULT_PASS=guest
REDIS_HOST=top-redis
REDIS_PORT=6379
REDIS_PASSWORD=insecure
92 changes: 0 additions & 92 deletions Jenkinsfile

This file was deleted.

47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.PHONY: manifests deploy

dc = docker-compose

ENVIRONMENT ?= local
HELM_ARGS = manifests/chart \
-f manifests/values.yaml \
-f manifests/env/${ENVIRONMENT}.yaml \
--set image.tag=${VERSION}

REGISTRY ?= 127.0.0.1:5001
REPOSITORY ?= salmagundi/zaken-backend
VERSION ?= latest

build:
$(dc) build

test:
echo "No tests available"

migrate:

push:
$(dc) push


manifests:
@helm template top $(HELM_ARGS) $(ARGS)

deploy: manifests
helm upgrade --install top $(HELM_ARGS) $(ARGS)

update-chart:
rm -rf manifests/chart
git clone --branch 1.5.2 --depth 1 [email protected]:Amsterdam/helm-application.git manifests/chart
rm -rf manifests/chart/.git

clean:
$(dc) down -v --remove-orphans

reset:
helm uninstall top

refresh: reset build push deploy

dev:
nohup kubycat kubycat-config.yaml > /dev/null 2>&1&
6 changes: 4 additions & 2 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ RUN pip install uwsgi
RUN pip install --no-cache-dir -r requirements.txt

COPY . /app/
COPY deploy /deploy/


RUN chmod +x /app/wait-for.sh
RUN chmod +x /app/celery.sh
RUN chmod +x /app/celery-beat.sh
RUN chmod +x /app/deploy/entrypoint.sh

CMD ["/deploy/entrypoint.sh"]
ENTRYPOINT ["/app/deploy/entrypoint.sh"]
CMD ["uwsgi", "--ini", "/app/deploy/config.ini"]
2 changes: 1 addition & 1 deletion app/apps/cases/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def fetch_case(self, auth_header=None):
}
response = requests.get(
url,
timeout=5,
timeout=10,
params=queryParams,
headers=get_headers(auth_header),
)
Expand Down
2 changes: 1 addition & 1 deletion app/apps/fraudprediction/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def fraudpredict_vakantieverhuur_task(self):
"""
This task is still being called by Celery.
If Celery cannot find this task it will generate a KeyError and celery will stop.
To prevent failures in production just pass this task and write a log to Sentry.
To prevent failures in production just pass this task.
TODO: Remove this over time.
"""
logger.error("The 'fraudpredict_vakantieverhuur_task' is called by Celery")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.13 on 2024-05-14 10:04

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("itinerary", "0069_itinerarysettings_districts"),
]

operations = [
migrations.AddField(
model_name="itinerarysettings",
name="subjects",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
null=True,
size=None,
),
),
migrations.AddField(
model_name="itinerarysettings",
name="tags",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
null=True,
size=None,
),
),
]
12 changes: 12 additions & 0 deletions app/apps/itinerary/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ class ItinerarySettings(models.Model):
blank=True,
null=True,
)
subjects = ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
null=True,
)
tags = ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
null=True,
)
districts = ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
Expand Down Expand Up @@ -261,6 +271,8 @@ def get_cases_query_params(self):
"district": self.districts,
"project": self.project_ids,
"priority": self.priorities,
"subject": self.subjects,
"tag": self.tags,
}
)
return cases_query_params
Expand Down
4 changes: 4 additions & 0 deletions app/apps/itinerary/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Meta:
"reasons",
"state_types",
"project_ids",
"subjects",
"tags",
"housing_corporations",
)

Expand Down Expand Up @@ -149,6 +151,8 @@ def create(self, validated_data):
week_segments=day_settings.week_segments,
priorities=day_settings.priorities,
project_ids=day_settings.project_ids,
subjects=day_settings.subjects,
tags=day_settings.tags,
districts=day_settings.districts,
housing_corporations=day_settings.housing_corporations,
housing_corporation_combiteam=day_settings.housing_corporation_combiteam,
Expand Down
2 changes: 2 additions & 0 deletions app/apps/planner/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class DaySettingsInline(admin.TabularInline):
"max_use_limit",
"start_time",
"project_ids",
"subjects",
"tags",
)
},
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.13 on 2024-05-14 10:04

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("planner", "0040_daysettings_districts"),
]

operations = [
migrations.AddField(
model_name="daysettings",
name="subjects",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
null=True,
size=None,
),
),
migrations.AddField(
model_name="daysettings",
name="tags",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
null=True,
size=None,
),
),
]
36 changes: 36 additions & 0 deletions app/apps/planner/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ def fetch_team_reasons(self, auth_header=None):

return response.json().get("results", [])

def fetch_subjects(self, auth_header=None):
url = f"{settings.ZAKEN_API_URL}/themes/{self.zaken_team_id}/subjects/"

response = requests.get(
url,
timeout=5,
headers=get_headers(auth_header),
)
response.raise_for_status()

return response.json().get("results", [])

def fetch_tags(self, auth_header=None):
url = f"{settings.ZAKEN_API_URL}/themes/{self.zaken_team_id}/tags/"

response = requests.get(
url,
timeout=5,
headers=get_headers(auth_header),
)
response.raise_for_status()

return response.json().get("results", [])

class Meta:
verbose_name_plural = "Team settings"
ordering = ["name"]
Expand Down Expand Up @@ -231,6 +255,16 @@ class DaySettings(models.Model):
blank=True,
null=True,
)
subjects = ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
null=True,
)
tags = ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
null=True,
)
districts = ArrayField(
base_field=models.PositiveSmallIntegerField(),
blank=True,
Expand Down Expand Up @@ -278,6 +312,8 @@ def get_cases_query_params(self):
"schedule_week_segment": self.week_segments,
"project": self.project_ids,
"reason": self.reasons,
"subject": self.subjects,
"tag": self.tags,
"district": self.districts,
"priority": self.priorities,
}
Expand Down
Loading

0 comments on commit 0ce83ce

Please sign in to comment.