Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nycmeshnet/meshdb
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 158e601e4c081e09e61e738c4825efb12a2e51b3
Choose a base ref
..
head repository: nycmeshnet/meshdb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6ff3b6afdd7917e1f41ae208c88d3b087018c983
Choose a head ref
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
7 changes: 4 additions & 3 deletions .github/workflows/publish-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -10,14 +10,15 @@ on:

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
push_to_registry:
name: Push Docker Image to Docker Hub
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Check out the repo
uses: actions/checkout@v4
58 changes: 2 additions & 56 deletions infra/helm/meshdb/charts/celery/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -44,62 +44,8 @@ spec:
envFrom:
- configMapRef:
name: meshdbconfig
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: postgres-password
- name: DB_PASSWORD_RO
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: postgres-password-ro
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: aws-access-key-id
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: aws-secret-access-key
- name: SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: smtp-password
- name: DJANGO_SECRET_KEY
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: django-secret-key
- name: NN_ASSIGN_PSK
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: nn-assign-psk
- name: QUERY_PSK
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: query-psk
- name: PANO_GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: pano-github-token
- name: UISP_PASS
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: uisp-pass
- name: SLACK_ADMIN_NOTIFICATIONS_WEBHOOK_URL
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: slack-webhook
- secretRef:
name: meshdb-secrets
{{- if .livenessProbe }}
livenessProbe:
{{- toYaml .livenessProbe | nindent 12 }}
79 changes: 3 additions & 76 deletions infra/helm/meshdb/templates/meshweb.yaml
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ spec:
selector:
matchLabels:
{{- include "meshdb.selectorLabels" . | nindent 6 }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
annotations:
@@ -39,82 +40,8 @@ spec:
envFrom:
- configMapRef:
name: meshdbconfig
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: postgres-password
- name: DB_PASSWORD_RO
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: postgres-password-ro
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: aws-access-key-id
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: aws-secret-access-key
- name: SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: smtp-password
- name: DJANGO_SECRET_KEY
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: django-secret-key
- name: NN_ASSIGN_PSK
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: nn-assign-psk
- name: QUERY_PSK
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: query-psk
- name: PANO_GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: pano-github-token
- name: UISP_PASS
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: uisp-pass
- name: SLACK_ADMIN_NOTIFICATIONS_WEBHOOK_URL
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: slack-webhook
- name: SLACK_JOIN_REQUESTS_CHANNEL_WEBHOOK_URL
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: slack-join-webhook
- name: OSTICKET_API_TOKEN
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: osticket-api-token
- name: RECAPTCHA_SERVER_SECRET_KEY_V2
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: recaptcha-v2-secret
- name: RECAPTCHA_SERVER_SECRET_KEY_V3
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: recaptcha-v3-secret
- secretRef:
name: meshdb-secrets
volumeMounts:
- name: static-content-vol
mountPath: /opt/meshdb/static
1 change: 1 addition & 0 deletions infra/helm/meshdb/templates/nginx.yaml
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ spec:
selector:
matchLabels:
{{- include "meshdb.selectorLabels" . | nindent 6 }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
{{- with .Values.podAnnotations }}
1 change: 1 addition & 0 deletions infra/helm/meshdb/templates/pelias.yaml
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ spec:
selector:
matchLabels:
{{- include "meshdb.selectorLabels" . | nindent 6 }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
{{- with .Values.podAnnotations }}
3 changes: 2 additions & 1 deletion infra/helm/meshdb/templates/postgres.yaml
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ spec:
{{- include "meshdb.selectorLabels" . | nindent 6 }}
strategy:
type: Recreate
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
{{- with .Values.podAnnotations }}
@@ -66,7 +67,7 @@ spec:
valueFrom:
secretKeyRef:
name: meshdb-secrets
key: postgres-password
key: DB_PASSWORD
- name: PGDATA
value: "/var/lib/postgresql/data/meshdb_data"
volumeMounts:
1 change: 1 addition & 0 deletions infra/helm/meshdb/templates/redis.yaml
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ spec:
selector:
matchLabels:
{{- include "meshdb.selectorLabels" . | nindent 6 }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
annotations:
30 changes: 15 additions & 15 deletions infra/helm/meshdb/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -5,18 +5,18 @@ metadata:
namespace: {{ .Values.meshdb_app_namespace }}
type: Opaque
data:
postgres-password: {{ .Values.pg.password | b64enc | quote }}
postgres-password-ro: {{ .Values.pg.password_ro | b64enc | quote }}
aws-access-key-id: {{ .Values.aws.access_key_id | b64enc | quote }}
aws-secret-access-key: {{ .Values.aws.secret_access_key | b64enc | quote }}
smtp-password: {{ .Values.email.smtp_password | b64enc | quote }}
django-secret-key: {{ .Values.meshweb.django_secret_key | b64enc | quote }}
nn-assign-psk: {{ .Values.meshweb.nn_assign_psk | b64enc | quote }}
query-psk: {{ .Values.meshweb.query_psk | b64enc | quote }}
uisp-pass: {{ .Values.uisp.psk | b64enc | quote }}
pano-github-token: {{ .Values.meshweb.pano_github_token | b64enc | quote }}
slack-webhook: {{ .Values.meshweb.slack_webhook | b64enc | quote }}
slack-join-webhook: {{ .Values.meshweb.slack_join_webhook | b64enc | quote }}
osticket-api-token: {{ .Values.meshweb.osticket_api_token | b64enc | quote }}
recaptcha-v2-secret: {{ .Values.meshweb.recaptcha_v2_secret | b64enc | quote }}
recaptcha-v3-secret: {{ .Values.meshweb.recaptcha_v3_secret | b64enc | quote }}
DB_PASSWORD: {{ .Values.pg.password | b64enc | quote }}
DB_PASSWORD_RO: {{ .Values.pg.password_ro | b64enc | quote }}
AWS_ACCESS_KEY_ID: {{ .Values.aws.access_key_id | b64enc | quote }}
AWS_SECRET_ACCESS_KEY: {{ .Values.aws.secret_access_key | b64enc | quote }}
SMTP_PASSWORD: {{ .Values.email.smtp_password | b64enc | quote }}
DJANGO_SECRET_KEY: {{ .Values.meshweb.django_secret_key | b64enc | quote }}
NN_ASSIGN_PSK: {{ .Values.meshweb.nn_assign_psk | b64enc | quote }}
QUERY_PSK: {{ .Values.meshweb.query_psk | b64enc | quote }}
PANO_GITHUB_TOKEN: {{ .Values.meshweb.pano_github_token | b64enc | quote }}
UISP_PASS: {{ .Values.uisp.psk | b64enc | quote }}
SLACK_ADMIN_NOTIFICATIONS_WEBHOOK_URL: {{ .Values.meshweb.slack_webhook | b64enc | quote }}
SLACK_JOIN_REQUESTS_CHANNEL_WEBHOOK_URL: {{ .Values.meshweb.slack_join_webhook | b64enc | quote }}
OSTICKET_API_TOKEN: {{ .Values.meshweb.osticket_api_token | b64enc | quote }}
RECAPTCHA_SERVER_SECRET_KEY_V2: {{ .Values.meshweb.recaptcha_v2_secret | b64enc | quote }}
RECAPTCHA_SERVER_SECRET_KEY_V3: {{ .Values.meshweb.recaptcha_v3_secret | b64enc | quote }}
2 changes: 2 additions & 0 deletions infra/helm/meshdb/values.yaml
Original file line number Diff line number Diff line change
@@ -143,3 +143,5 @@ autoscaling:
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

revisionHistoryLimit: 4
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ dependencies = [
"prettytable==3.11.*",
"matplotlib==3.9.*",
"django-ipware==7.0.1",
"django-admin-site-search==1.1.*",
]

[project.optional-dependencies]
@@ -52,7 +53,7 @@ dev = [
"pytest == 7.4.*",
"parameterized == 0.9.*",
"flake8 == 6.1.*",
"black == 23.7.*",
"black == 24.10.*",
"isort == 5.12.*",
"coverage == 7.3.*",
"mypy == 1.10.0",
2 changes: 1 addition & 1 deletion src/meshapi/management/commands/create_groups.py
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ def create_base_groups(self) -> None:
if (act == "change" and obj in models) or (act == "view" and obj in models) or code == "assign_nn":
installer.permissions.add(p)

if act == "add" and obj == "accesspoint":
if act == "add" and obj in ["accesspoint", "link"]:
installer.permissions.add(p)

# admin
3 changes: 1 addition & 2 deletions src/meshapi/models/building.py
Original file line number Diff line number Diff line change
@@ -18,8 +18,7 @@ class AddressTruthSource(Enum):
NYCPlanningLabs = "NYCPlanningLabs"
PeliasStringParsing = "PeliasStringParsing"
ReverseGeocodeFromCoordinates = "ReverseGeocodeFromCoordinates"
HumanEntry = "HumanEntry" # Volunteers
JoinFormEntry = "JoinFormEntry" # Random Humans
HumanEntry = "HumanEntry"


class Building(models.Model):
2 changes: 2 additions & 0 deletions src/meshapi/serializers/query_api.py
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ class Meta:
"additional_email_addresses",
"notes",
"network_number",
"network_number_status",
"status",
)

@@ -42,6 +43,7 @@ class Meta:
)

network_number = serializers.IntegerField(source="node.network_number", allow_null=True)
network_number_status = serializers.CharField(source="node.status", allow_null=True)

primary_email_address = serializers.CharField(source="member.primary_email_address")
stripe_email_address = serializers.CharField(source="member.stripe_email_address")
4 changes: 2 additions & 2 deletions src/meshapi/tasks.py
Original file line number Diff line number Diff line change
@@ -101,11 +101,11 @@ def run_update_from_uisp() -> None:
if MESHDB_ENVIRONMENT == "prod2":
celery_app.conf.beat_schedule["run-database-backup-hourly"] = {
"task": "meshapi.tasks.run_database_backup",
"schedule": crontab(minute="20", hour="*/1"),
"schedule": crontab(minute="40", hour="*/1"),
}

if MESHDB_ENVIRONMENT == "dev3":
celery_app.conf.beat_schedule["run-reset-dev-database-daily"] = {
"task": "meshapi.tasks.run_database_backup",
"schedule": crontab(minute="30", hour="0"),
"schedule": crontab(minute="45", hour="0"),
}
37 changes: 37 additions & 0 deletions src/meshapi/tests/sample_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from geopy import Location, Point

from meshapi.models import Device, Install, Node

sample_member = {
@@ -57,3 +59,38 @@
}
]
}


sample_osm_address_response = Location(
"151, Broome Street, Manhattan Community Board 3, Manhattan, New York County, City of New York, New York, 10002, United States",
Point(40.7162281, -73.98489654157149, 0.0),
{
"address": {
"ISO3166-2-lvl4": "US-NY",
"city": "City of New York",
"country": "United States",
"country_code": "us",
"county": "New York County",
"house_number": "151",
"neighbourhood": "Manhattan Community Board 3",
"postcode": "10002",
"road": "Broome Street",
"state": "New York",
"suburb": "Manhattan",
},
"addresstype": "building",
"boundingbox": ["40.7160582", "40.7164320", "-73.9852426", "-73.9847390"],
"class": "building",
"display_name": "151, Broome Street, Manhattan Community Board 3, Manhattan, New York County, City of New York, New York, 10002, United States",
"importance": 9.175936522464359e-05,
"lat": "40.7162281",
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
"lon": "-73.98489654157149",
"name": "",
"osm_id": 250268365,
"osm_type": "way",
"place_id": 333450671,
"place_rank": 30,
"type": "yes",
},
)
Loading