mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
@@ -0,0 +1,20 @@
|
||||
from django.db import models
|
||||
|
||||
IGNORED_ATTRS = ['verbose_name', 'help_text']
|
||||
|
||||
original_deconstruct = models.Field.deconstruct
|
||||
|
||||
|
||||
def new_deconstruct(self):
|
||||
# works around the non-fix of https://code.djangoproject.com/ticket/21498 (I don't agree with the reasoning that
|
||||
# "in principle any field could influence the database schema"; you must be _insane_ if verbose_name or help_text
|
||||
# actually do, and the cost of the migrations is real)
|
||||
# solution from https://stackoverflow.com/a/39801321/339144
|
||||
name, path, args, kwargs = original_deconstruct(self)
|
||||
for attr in IGNORED_ATTRS:
|
||||
kwargs.pop(attr, None)
|
||||
return name, path, args, kwargs
|
||||
|
||||
|
||||
def monkey_patch_deconstruct():
|
||||
models.Field.deconstruct = new_deconstruct
|
||||
|
||||
8
bsmain/management/commands/makemigrations.py
Normal file
8
bsmain/management/commands/makemigrations.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from django.core.management.commands.makemigrations import Command as OriginalCommand
|
||||
|
||||
from . import monkey_patch_deconstruct
|
||||
monkey_patch_deconstruct()
|
||||
|
||||
|
||||
class Command(OriginalCommand):
|
||||
pass # no changes, except the monkey patch above
|
||||
@@ -1,6 +1,9 @@
|
||||
import time
|
||||
from django.core.management.commands.migrate import Command as DjangoMigrateCommand
|
||||
|
||||
from . import monkey_patch_deconstruct
|
||||
monkey_patch_deconstruct() # needed for migrate.py to avoid the warning about non-reflected changes
|
||||
|
||||
|
||||
class Command(DjangoMigrateCommand):
|
||||
# We override the default Django migrate command to add the elapsed time for each migration. (This could in theory
|
||||
@@ -10,8 +13,7 @@ class Command(DjangoMigrateCommand):
|
||||
# We care more about the elapsed time for each migration than the average Django user because sqlite takes such a
|
||||
# prominent role in our architecture, and because migrations are run out of our direct control ("self hosted").
|
||||
#
|
||||
# AFAIU, "just dropping a file called migrate.py in one of our apps" is good enough to be the override (and if it
|
||||
# isn't, it's not critical, since all we do is add a bit more info to the output).
|
||||
# AFAIU, "just dropping a file called migrate.py in one of our apps" is good enough to be the override.
|
||||
|
||||
def migration_progress_callback(self, action, migration=None, fake=False):
|
||||
# Django 4.2's method, with a single change
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}Auth Tokens · {{ site_title }}{% endblock %}
|
||||
{% block title %}{% translate "Auth Tokens" %} · {{ site_title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
@@ -19,12 +20,12 @@
|
||||
{% endif %}
|
||||
|
||||
<div class="flex">
|
||||
<h1 class="text-4xl mt-4 font-bold">Auth Tokens</h1>
|
||||
<h1 class="text-4xl mt-4 font-bold">{% translate "Auth Tokens" %}</h1>
|
||||
|
||||
<div class="ml-auto mt-6">
|
||||
<form action="{% url "auth_token_create" %}" method="post">
|
||||
{% csrf_token %} {# margins display slightly different from the <a href version that I have for e.g. project memembers, but I don't care _that_ much #}
|
||||
<button class="font-bold text-slate-800 dark:text-slate-100 border-slate-500 dark:border-slate-400 pl-4 pr-4 pb-2 pt-2 ml-1 border-2 bg-cyan-200 dark:bg-cyan-700 hover:bg-cyan-400 dark:hover:bg-cyan-600 active:ring rounded-md">Add Token</button>
|
||||
<button class="font-bold text-slate-800 dark:text-slate-100 border-slate-500 dark:border-slate-400 pl-4 pr-4 pb-2 pt-2 ml-1 border-2 bg-cyan-200 dark:bg-cyan-700 hover:bg-cyan-400 dark:hover:bg-cyan-600 active:ring rounded-md">{% translate "Add Token" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -37,7 +38,7 @@
|
||||
<tbody>
|
||||
<thead>
|
||||
<tr class="bg-slate-200 dark:bg-slate-800">
|
||||
<th class="w-full p-4 text-left text-xl" colspan="2">Auth Tokens</th>
|
||||
<th class="w-full p-4 text-left text-xl" colspan="2">{% translate "Auth Tokens" %}</th>
|
||||
</tr>
|
||||
|
||||
{% for auth_token in auth_tokens %}
|
||||
@@ -50,7 +51,7 @@
|
||||
|
||||
<td class="p-4">
|
||||
<div class="flex justify-end">
|
||||
<button name="action" value="delete:{{ auth_token.id }}" class="font-bold text-slate-500 dark:text-slate-300 border-slate-300 dark:border-slate-600 pl-4 pr-4 pb-2 pt-2 ml-2 border-2 hover:bg-slate-200 dark:hover:bg-slate-800 active:ring rounded-md">Delete</button>
|
||||
<button name="action" value="delete:{{ auth_token.id }}" class="font-bold text-slate-500 dark:text-slate-300 border-slate-300 dark:border-slate-600 pl-4 pr-4 pb-2 pt-2 ml-2 border-2 hover:bg-slate-200 dark:hover:bg-slate-800 active:ring rounded-md whitespace-nowrap">{% translate "Delete" %}</button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -59,7 +60,7 @@
|
||||
<tr class="bg-white dark:bg-slate-900 border-slate-200 dark:border-slate-700 border-b-2">
|
||||
<td class="w-full p-4">
|
||||
<div>
|
||||
No Auth Tokens.
|
||||
{% translate "No Auth Tokens." %}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ from django.shortcuts import render, redirect
|
||||
from django.http import Http404
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from bugsink.decorators import atomic_for_request_method
|
||||
|
||||
@@ -20,7 +21,7 @@ def auth_token_list(request):
|
||||
if action == "delete":
|
||||
AuthToken.objects.get(pk=pk).delete()
|
||||
|
||||
messages.success(request, 'Token deleted')
|
||||
messages.success(request, _('Token deleted'))
|
||||
return redirect('auth_token_list')
|
||||
|
||||
return render(request, 'bsmain/auth_token_list.html', {
|
||||
|
||||
Reference in New Issue
Block a user