Added to set the current user of the data model if the model is our BaseModel in the fill_model_from_form() method in FormView in the Mia core application.
This commit is contained in:
parent
a6fc865b3e
commit
321165a50f
@ -32,6 +32,7 @@ from django.views.generic import DeleteView as CoreDeleteView
|
|||||||
from django.views.generic.base import View
|
from django.views.generic.base import View
|
||||||
|
|
||||||
from . import stored_post, utils
|
from . import stored_post, utils
|
||||||
|
from .models import BaseModel
|
||||||
from .utils import UrlBuilder
|
from .utils import UrlBuilder
|
||||||
|
|
||||||
|
|
||||||
@ -126,6 +127,8 @@ class FormView(View):
|
|||||||
"""Fills in the data model from the form."""
|
"""Fills in the data model from the form."""
|
||||||
for name in form.fields:
|
for name in form.fields:
|
||||||
setattr(obj, name, form[name].value())
|
setattr(obj, name, form[name].value())
|
||||||
|
if isinstance(obj, BaseModel):
|
||||||
|
obj.current_user = self.request.user
|
||||||
|
|
||||||
def form_invalid(self, form: forms.Form) -> HttpResponseRedirect:
|
def form_invalid(self, form: forms.Form) -> HttpResponseRedirect:
|
||||||
"""Handles the action when the POST form is invalid."""
|
"""Handles the action when the POST form is invalid."""
|
||||||
|
Loading…
Reference in New Issue
Block a user