Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ DEBUG=True
# ALLOWED_HOSTS=alerts.solvro.pl,localhost
# CORS_ALLOWED_ORIGINS=https://solvro.pl,http://localhost:8000

# === DRF Rate Limiting ===
# NUM_PROXIES=1
# THROTTLE_PUBLIC_REPORT_BURST=3/min
# THROTTLE_PUBLIC_REPORT_SUSTAINED=10/hour

# === Database ===
# DB_ENGINE=django.db.backends.postgresql
# DB_NAME=your_db_name
Expand All @@ -12,6 +17,9 @@ DEBUG=True
# DB_HOST=localhost
# DB_PORT=5432

# === S3 / Storage Configuration ===
# S3_BASE_URL=https://example-s3.local/

# === Authentication ===
#SOLVRO_AUTH_CLIENT_ID=solvro-alerts
#SOLVRO_AUTH_CLIENT_SECRET=your-solvro-auth-client-secret
#SOLVRO_AUTH_CLIENT_SECRET=your-solvro-auth-client-secret
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,7 @@ cython_debug/
db.json

# macOS
.DS_Store
.DS_Store

# Zed
.zed
21 changes: 20 additions & 1 deletion backend_solvro_feedback/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import logging
import os
from pathlib import Path
import dotenv

import dotenv

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -55,6 +55,8 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"reports",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -137,3 +139,20 @@
# https://docs.djangoproject.com/en/6.0/howto/static-files/

STATIC_URL = "static/"

S3_BASE_URL = os.getenv("S3_BASE_URL", "https://example-s3.local/")

NUM_PROXIES_ENV = os.getenv("NUM_PROXIES")

REST_FRAMEWORK = {
"NUM_PROXIES": int(NUM_PROXIES_ENV) if NUM_PROXIES_ENV is not None else None,
"DEFAULT_THROTTLE_CLASSES": [
"rest_framework.throttling.ScopedRateThrottle",
],
"DEFAULT_THROTTLE_RATES": {
"public_report_burst": os.getenv("THROTTLE_PUBLIC_REPORT_BURST", "3/min"),
"public_report_sustained": os.getenv(
"THROTTLE_PUBLIC_REPORT_SUSTAINED", "10/hour"
),
},
}
3 changes: 2 additions & 1 deletion backend_solvro_feedback/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"""

from django.contrib import admin
from django.urls import path
from django.urls import include, path

urlpatterns = [
path("admin/", admin.site.urls),
path("", include("reports.urls")),
]
Empty file added reports/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions reports/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.contrib import admin

from .models import Application, Issue, IssueAttachment


@admin.register(Application)
class ApplicationAdmin(admin.ModelAdmin):
list_display = ("name", "is_active", "repo_url")
list_filter = ("is_active",)
search_fields = ("name", "repo_url")


@admin.register(Issue)
class IssueAdmin(admin.ModelAdmin):
list_display = ("title", "application", "status", "created_at")
list_filter = ("status", "application")
search_fields = ("title", "description")
readonly_fields = ("created_at", "updated_at")


@admin.register(IssueAttachment)
class IssueAttachmentAdmin(admin.ModelAdmin):
list_display = ("filename", "issue", "content_type", "size", "created_at")
search_fields = ("filename", "issue__title")
readonly_fields = ("created_at",)
5 changes: 5 additions & 0 deletions reports/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ReportsConfig(AppConfig):
name = "reports"
139 changes: 139 additions & 0 deletions reports/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Generated by Django 6.0.3 on 2026-03-31 18:50

import django.core.validators
import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="Application",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("name", models.CharField(max_length=120, unique=True)),
("repo_url", models.URLField(max_length=500)),
("is_active", models.BooleanField(default=True)),
],
),
migrations.CreateModel(
name="Issue",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"title",
models.CharField(
max_length=200,
validators=[django.core.validators.MinLengthValidator(3)],
),
),
(
"description",
models.TextField(
validators=[django.core.validators.MinLengthValidator(10)]
),
),
("diagnostics", models.JSONField(blank=True, null=True)),
(
"status",
models.CharField(
choices=[
("NEW", "New"),
("VERIFIED", "Verified"),
("GITHUB_CREATED", "GitHub created"),
("REJECTED", "Rejected"),
],
db_index=True,
default="NEW",
max_length=20,
),
),
(
"github_issue_number",
models.PositiveIntegerField(blank=True, null=True),
),
(
"github_issue_url",
models.URLField(blank=True, max_length=500, null=True),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"application",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="issues",
to="reports.application",
),
),
(
"author",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="reported_issues",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"ordering": ["-created_at"],
},
),
migrations.CreateModel(
name="IssueAttachment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("original_filename", models.CharField(max_length=255)),
("s3_key", models.CharField(max_length=500)),
("file_url", models.URLField(max_length=1000)),
("content_type", models.CharField(max_length=100)),
("size", models.PositiveIntegerField(help_text="File size in bytes")),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"issue",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="attachments",
to="reports.issue",
),
),
],
options={
"ordering": ["created_at"],
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 6.0.3 on 2026-03-31 20:49

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("reports", "0001_initial"),
]

operations = [
migrations.RenameField(
model_name="issueattachment",
old_name="original_filename",
new_name="filename",
),
]
Empty file added reports/migrations/__init__.py
Empty file.
76 changes: 76 additions & 0 deletions reports/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import uuid

from django.conf import settings
from django.core.validators import MinLengthValidator
from django.db import models


class IssueStatus(models.TextChoices):
NEW = "NEW", "New"
VERIFIED = "VERIFIED", "Verified"
GITHUB_CREATED = "GITHUB_CREATED", "GitHub created"
REJECTED = "REJECTED", "Rejected"


class Application(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=120, unique=True)
repo_url = models.URLField(max_length=500)
is_active = models.BooleanField(default=True)

def __str__(self) -> str:
return self.name


class Issue(models.Model):
application = models.ForeignKey(
Application,
on_delete=models.CASCADE,
related_name="issues",
)
author = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="reported_issues",
)
title = models.CharField(max_length=200, validators=[MinLengthValidator(3)])
description = models.TextField(validators=[MinLengthValidator(10)])
diagnostics = models.JSONField(blank=True, null=True)
status = models.CharField(
max_length=20,
choices=IssueStatus.choices,
default=IssueStatus.NEW,
db_index=True,
)
github_issue_number = models.PositiveIntegerField(null=True, blank=True)
github_issue_url = models.URLField(max_length=500, null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
ordering = ["-created_at"]

def __str__(self) -> str:
return f"[{self.status}] {self.title}"


class IssueAttachment(models.Model):
issue = models.ForeignKey(
Issue,
on_delete=models.CASCADE,
related_name="attachments",
)
filename = models.CharField(max_length=255)
s3_key = models.CharField(max_length=500)
file_url = models.URLField(max_length=1000)
content_type = models.CharField(max_length=100)
size = models.PositiveIntegerField(help_text="File size in bytes")
created_at = models.DateTimeField(auto_now_add=True)

class Meta:
ordering = ["created_at"]

def __str__(self) -> str:
return self.filename
Loading
Loading