[UPDT] BASE: Changed comment view from modal to activity sidebar
This commit is contained in:
@@ -24,6 +24,7 @@ from base.models import (
|
||||
AnnouncementComment,
|
||||
AnnouncementExpire,
|
||||
Attachment,
|
||||
BaserequestFile,
|
||||
Company,
|
||||
Department,
|
||||
DynamicEmailConfiguration,
|
||||
@@ -50,6 +51,8 @@ from base.methods import reload_queryset
|
||||
from horilla_audit.models import AuditTag
|
||||
from horilla_widgets.widgets.horilla_multi_select_field import HorillaMultiSelectField
|
||||
from horilla_widgets.widgets.select_widgets import HorillaMultiSelectWidget
|
||||
from employee.forms import MultipleFileField
|
||||
|
||||
|
||||
# your form here
|
||||
|
||||
@@ -1550,6 +1553,48 @@ class ShiftrequestcommentForm(ModelForm):
|
||||
|
||||
model = ShiftrequestComment
|
||||
fields = ('comment',)
|
||||
|
||||
|
||||
class shiftCommentForm(ModelForm):
|
||||
"""
|
||||
Shift request comment model form
|
||||
"""
|
||||
|
||||
verbose_name = "Add Comment"
|
||||
|
||||
class Meta:
|
||||
model = ShiftrequestComment
|
||||
fields = "__all__"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["files"] = MultipleFileField(label="files")
|
||||
self.fields["files"].required = False
|
||||
|
||||
def as_p(self):
|
||||
"""
|
||||
Render the form fields as HTML table rows with Bootstrap styling.
|
||||
"""
|
||||
context = {"form": self}
|
||||
table_html = render_to_string("common_form.html", context)
|
||||
return table_html
|
||||
|
||||
def save(self, commit: bool = ...) -> Any:
|
||||
multiple_files_ids = []
|
||||
files = None
|
||||
if self.files.getlist("files"):
|
||||
files = self.files.getlist("files")
|
||||
self.instance.attachemnt = files[0]
|
||||
multiple_files_ids = []
|
||||
for attachemnt in files:
|
||||
file_instance = BaserequestFile()
|
||||
file_instance.file = attachemnt
|
||||
file_instance.save()
|
||||
multiple_files_ids.append(file_instance.pk)
|
||||
instance = super().save(commit)
|
||||
if commit:
|
||||
instance.files.add(*multiple_files_ids)
|
||||
return instance, files
|
||||
|
||||
|
||||
class WorktyperequestcommentForm(ModelForm):
|
||||
|
||||
Reference in New Issue
Block a user