Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ repos:
- id: debug-statements
- id: detect-private-key

- repo: https://github.com/adamchainz/django-upgrade
rev: "1.29.0" # replace with latest tag on GitHub
hooks:
- id: django-upgrade

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
Expand Down
24 changes: 6 additions & 18 deletions acl/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


# class MachineAdmin(ImportExportModelAdmin,admin.ModelAdmin):
@admin.register(Machine)
class MachineAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = (
"name",
Expand All @@ -26,24 +27,20 @@ class MachineAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
)


admin.site.register(Machine, MachineAdmin)


# class LocationAdmin(ImportExportModelAdmin,admin.ModelAdmin):
@admin.register(Location)
class LocationAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("name", "description")


admin.site.register(Location, LocationAdmin)


class EntitlementResource(resources.ModelResource):
class Meta:
model = Entitlement
fields = ["permit", "holder", "issuer", "active"]
import_id_fields = ["permit", "holder", "issuer"]


@admin.register(Entitlement)
class EntitlementAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("permit", "holder", "issuer", "active", "issue_date")
resource_class = EntitlementResource
Expand Down Expand Up @@ -77,27 +74,21 @@ def get_changeform_initial_data(self, request):
return defaults


admin.site.register(Entitlement, EntitlementAdmin)


@admin.register(PermitType)
class PermitAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("name", "description", "require_ok_trustee", "permit")


admin.site.register(PermitType, PermitAdmin)


@admin.register(RecentUse)
class RecentUseAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("user", "machine", "used")


admin.site.register(RecentUse, RecentUseAdmin)


# We lock this class down - as making changes is rather
# confusing for the (payment/access) nodes; as this controls
# their caching and updates.
#
@admin.register(ChangeTracker)
class ChangeTrackerAdmin(admin.ModelAdmin):
class Meta:
view_only = True
Expand All @@ -113,6 +104,3 @@ def has_change_permission(self, request, rec=None):

def has_delete_permission(self, request, rec=None):
return False


admin.site.register(ChangeTracker, ChangeTrackerAdmin)
4 changes: 2 additions & 2 deletions agenda/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ def AgendaUpdateStatusView(request, pk):
messages.success(request, "The item is updated successfully.")
else:
messages.error(request, "The item could not be updated.")
return redirect(request.META.get("HTTP_REFERER", "/"))
return redirect(request.headers.get("referer", "/"))
else:
return redirect(request.META.get("HTTP_REFERER", "/"))
return redirect(request.headers.get("referer", "/"))


@login_required
Expand Down
6 changes: 2 additions & 4 deletions chores/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .models import Chore, ChoreVolunteer


@admin.register(Chore)
class ChoreAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = (
"name",
Expand All @@ -17,14 +18,11 @@ class ChoreAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
)


@admin.register(ChoreVolunteer)
class ChoreVolunteerAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = (
"user",
"chore",
"timestamp",
"created_at",
)


admin.site.register(Chore, ChoreAdmin)
admin.site.register(ChoreVolunteer, ChoreVolunteerAdmin)
8 changes: 2 additions & 6 deletions mailinglists/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
logger = logging.getLogger(__name__)


@admin.register(Mailinglist)
class MailinglistAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
pass


admin.site.register(Mailinglist, MailinglistAdmin)


def subscribe_selected(modeladmin, request, queryset):
for sub in queryset:
sub.active = True
Expand All @@ -34,9 +32,7 @@ def unsubscribe_selected(modeladmin, request, queryset):
unsubscribe_selected.short_description = "Deactivate selected"


@admin.register(Subscription)
class SubscriptionAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("mailinglist", "member", "active", "digest")
actions = [subscribe_selected, unsubscribe_selected]


admin.site.register(Subscription, SubscriptionAdmin)
4 changes: 1 addition & 3 deletions mainssensor/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from .models import Mainssensor


@admin.register(Mainssensor)
class MainssensorAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
resource_class = Mainssensor


admin.site.register(Mainssensor, MainssensorAdmin)
2 changes: 1 addition & 1 deletion makerspaceleiden/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def wrap(request, *args, **kwargs):
if request.user and type(request.user).__name__ == "User":
return function(request, *args, **kwargs)

x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR")
x_forwarded_for = request.headers.get("x-forwarded-for")
if x_forwarded_for:
ip = x_forwarded_for.split(",")[0]
else:
Expand Down
2 changes: 1 addition & 1 deletion makerspaceleiden/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def hexsha2pin(sha256_hex_a, sha256_hex_b):


def client_ip(request):
x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR")
x_forwarded_for = request.headers.get("x-forwarded-for")
if x_forwarded_for:
return x_forwarded_for.split(",")[0]
return request.META.get("REMOTE_ADDR")
Expand Down
4 changes: 1 addition & 3 deletions memberbox/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .models import Memberbox


@admin.register(Memberbox)
class MemberboxAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
search_fields = [
"location",
Expand All @@ -17,6 +18,3 @@ class MemberboxAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
"owner",
)
pass


admin.site.register(Memberbox, MemberboxAdmin)
12 changes: 3 additions & 9 deletions members/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Meta:
import_id_fields = ["owner", "tag"]


@admin.register(User)
class UserAdmin(
ImportExportModelAdmin,
BaseUserAdmin,
Expand Down Expand Up @@ -97,21 +98,14 @@ class UserAdmin(
import_id_fields = () # 'email', 'first_name', 'last_name', 'is_staff', 'form_on_file', 'last_login','date_joined')


admin.site.register(User, UserAdmin)


@admin.register(Tag)
class TagAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("tag", "owner", "last_used", "description")
resource_class = TagResource
search_fields = ["tag", "owner__first_name", "owner__last_name", "owner__email"]


admin.site.register(Tag, TagAdmin)


@admin.register(AuditRecord)
class AuditRecordAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("user", "action", "recorded")
resource_class = AuditRecord


admin.site.register(AuditRecord, AuditRecordAdmin)
6 changes: 3 additions & 3 deletions members/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def sudo(request):
)

rurl = reverse("index")
if "HTTP_REFERER" in request.META:
rurl = request.META["HTTP_REFERER"]
if "referer" in request.headers:
rurl = request.headers["referer"]
form = NewAuditRecordForm(None, initial={"return_to": rurl})
context = {
"label": "GDPR (AVG)",
Expand Down Expand Up @@ -202,4 +202,4 @@ def drop(request):
record.changereason = f"DROP in webinterface by {request.user} - but actual permission had already timed out."
record.save()

return redirect(request.META["HTTP_REFERER"])
return redirect(request.headers["referer"])
14 changes: 6 additions & 8 deletions pettycash/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
logger = logging.getLogger(__name__)


@admin.register(PettycashSku)
class PettycashSkuAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("pk", "name", "amount", "description")
form = PettycashSkuForm
Expand All @@ -34,6 +35,7 @@ class PettycashSkuAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
#


@admin.register(PettycashStation)
class PettycashStationAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("description", "location", "terminal")
formfield_overrides = {
Expand Down Expand Up @@ -88,6 +90,7 @@ def queryset(self, request, queryset):
return queryset


@admin.register(PettycashTransaction)
class PettycashTransactionAdmin(
ImportExportModelAdmin, SimpleHistoryWithDeletedAdmin, ExportActionMixin
):
Expand All @@ -103,12 +106,14 @@ class PettycashTransactionAdmin(
pass


@admin.register(PettycashBalanceCache)
class PettycashBalanceCacheAdmin(ImportExportModelAdmin, SimpleHistoryWithDeletedAdmin):
list_display = ("owner", "balance", "lasttxdate")
search_fields = ["owner__first_name", "owner__last_name"]
pass


@admin.register(PettycashReimbursementRequest)
class PettycashReimbursementRequestAdmin(
ImportExportModelAdmin, SimpleHistoryWithDeletedAdmin
):
Expand All @@ -123,14 +128,7 @@ class PettycashReimbursementRequestAdmin(
pass


@admin.register(PettycashImportRecord)
class PettycashImportRecordAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
list_display = ("date", "by")
pass


admin.site.register(PettycashSku, PettycashSkuAdmin)
admin.site.register(PettycashStation, PettycashStationAdmin)
admin.site.register(PettycashTransaction, PettycashTransactionAdmin)
admin.site.register(PettycashBalanceCache, PettycashBalanceCacheAdmin)
admin.site.register(PettycashReimbursementRequest, PettycashReimbursementRequestAdmin)
admin.site.register(PettycashImportRecord, PettycashImportRecordAdmin)
2 changes: 1 addition & 1 deletion pettycash/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def mtostr(m):


def client_ip(request):
x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR")
x_forwarded_for = request.headers.get("x-forwarded-for")
if x_forwarded_for:
return x_forwarded_for.split(",")[0]
return request.META.get("REMOTE_ADDR")
Expand Down
6 changes: 2 additions & 4 deletions pettycredit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
logger = logging.getLogger(__name__)


@admin.register(PettycreditClaim)
class PettycreditClaimAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
pass


@admin.register(PettycreditClaimChange)
class PettycreditClaimChangeAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
pass


admin.site.register(PettycreditClaim, PettycreditClaimAdmin)
admin.site.register(PettycreditClaimChange, PettycreditClaimChangeAdmin)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies = [
"babel>=2.17.0",
"rich>=14.2.0",
"sumup>=0.0.10",
"django-upgrade>=1.29.0",
]

[dependency-groups]
Expand Down
4 changes: 1 addition & 3 deletions selfservice/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from .models import WiFiNetwork


@admin.register(WiFiNetwork)
class WiFiNetworkAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
pass


admin.site.register(WiFiNetwork, WiFiNetworkAdmin)
6 changes: 2 additions & 4 deletions selfservice/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
from django.urls import include, path, re_path
from django.urls import include, path

from . import views

Expand Down Expand Up @@ -53,9 +53,7 @@
name="confirm_email",
),
# for the password reset by email.
re_path(
"^registration/", include("django.contrib.auth.urls"), name="password_reset"
),
path("registration/", include("django.contrib.auth.urls"), name="password_reset"),
]

if settings.GRAND_AMNESTY:
Expand Down
4 changes: 1 addition & 3 deletions servicelog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from .models import Servicelog


@admin.register(Servicelog)
class ServicelogAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
pass


admin.site.register(Servicelog, ServicelogAdmin)
4 changes: 1 addition & 3 deletions storage/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from .models import Storage


@admin.register(Storage)
class StorageAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
pass


admin.site.register(Storage, StorageAdmin)
4 changes: 1 addition & 3 deletions sumup_connector/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .models import Checkout


@admin.register(Checkout)
class CheckoutAdmin(ImportExportModelAdmin, SimpleHistoryAdmin):
readonly_fields = [
"extra_information",
Expand Down Expand Up @@ -57,6 +58,3 @@ def list_changes(self, obj):
print(f"\n{fields}\n")
return format_html(fields)
return None


admin.site.register(Checkout, CheckoutAdmin)
Loading
Loading