mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Django admin forms: do not mess up my specially crafted fields please
* no stripping * no introduction of '\r'
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Issue, Grouping, TurningPoint
|
||||
from .forms import IssueAdminForm
|
||||
|
||||
|
||||
class GroupingInline(admin.TabularInline):
|
||||
@@ -34,6 +35,8 @@ class TurningPointInline(admin.TabularInline):
|
||||
|
||||
@admin.register(Issue)
|
||||
class IssueAdmin(admin.ModelAdmin):
|
||||
form = IssueAdminForm
|
||||
|
||||
fields = [
|
||||
'project',
|
||||
'friendly_id',
|
||||
|
||||
@@ -9,3 +9,21 @@ class CommentForm(ModelForm):
|
||||
class Meta:
|
||||
model = TurningPoint
|
||||
fields = ['comment']
|
||||
|
||||
|
||||
class IssueAdminForm(ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
for fieldname in self.fields:
|
||||
self.fields[fieldname].strip = False
|
||||
|
||||
def clean_fixed_at(self):
|
||||
fixed_at = self.cleaned_data.get('fixed_at')
|
||||
fixed_at = fixed_at.replace("\r", "")
|
||||
return fixed_at
|
||||
|
||||
def clean_events_at(self):
|
||||
events_at = self.cleaned_data.get('events_at')
|
||||
events_at = events_at.replace("\r", "")
|
||||
return events_at
|
||||
|
||||
Reference in New Issue
Block a user