mirror of
https://github.com/inventree/InvenTree.git
synced 2025-09-04 01:35:54 +00:00
Add special view for displaying / editing notes field for part
This commit is contained in:
@@ -11,7 +11,7 @@ from django.shortcuts import get_object_or_404
|
||||
from django.shortcuts import HttpResponseRedirect
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.views.generic import DetailView, ListView, FormView
|
||||
from django.views.generic import DetailView, ListView, FormView, UpdateView
|
||||
from django.forms.models import model_to_dict
|
||||
from django.forms import HiddenInput, CheckboxInput
|
||||
|
||||
@@ -519,6 +519,34 @@ class PartCreate(AjaxCreateView):
|
||||
return initials
|
||||
|
||||
|
||||
class PartNotes(UpdateView):
|
||||
""" View for editing the 'notes' field of a Part object.
|
||||
Presents a live markdown editor.
|
||||
"""
|
||||
|
||||
context_object_name = 'part'
|
||||
# form_class = part_forms.EditNotesForm
|
||||
template_name = 'part/notes.html'
|
||||
model = Part
|
||||
|
||||
fields = ['notes']
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
||||
part = self.get_object()
|
||||
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
|
||||
ctx['editing'] = str2bool(self.request.GET.get('edit', ''))
|
||||
|
||||
ctx['starred'] = part.isStarredBy(self.request.user)
|
||||
ctx['disabled'] = not part.active
|
||||
|
||||
ctx['OrderStatus'] = OrderStatus
|
||||
|
||||
return ctx
|
||||
|
||||
|
||||
class PartDetail(DetailView):
|
||||
""" Detail view for Part object
|
||||
"""
|
||||
|
Reference in New Issue
Block a user