[UPDT] HORILLA: Updated multiple forms with date widget
This commit is contained in:
@@ -50,12 +50,6 @@ class AssetForm(ModelForm):
|
|||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
exclude = ["is_active"]
|
exclude = ["is_active"]
|
||||||
widgets = {
|
widgets = {
|
||||||
"asset_purchase_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
),
|
|
||||||
"expiry_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
),
|
|
||||||
"asset_lot_number_id": forms.Select(
|
"asset_lot_number_id": forms.Select(
|
||||||
attrs={"onchange": "batchNoChange($(this))"}
|
attrs={"onchange": "batchNoChange($(this))"}
|
||||||
),
|
),
|
||||||
@@ -347,9 +341,6 @@ class AssetReturnForm(ModelForm):
|
|||||||
model = AssetAssignment
|
model = AssetAssignment
|
||||||
fields = ["return_date", "return_condition", "return_status", "return_images"]
|
fields = ["return_date", "return_condition", "return_status", "return_images"]
|
||||||
widgets = {
|
widgets = {
|
||||||
"return_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100", "required": "true"}
|
|
||||||
),
|
|
||||||
"return_condition": forms.Textarea(
|
"return_condition": forms.Textarea(
|
||||||
attrs={
|
attrs={
|
||||||
"class": "oh-input oh-input--textarea oh-input--block",
|
"class": "oh-input oh-input--textarea oh-input--block",
|
||||||
@@ -370,8 +361,7 @@ class AssetReturnForm(ModelForm):
|
|||||||
Initializes the AssetReturnForm with initial values and custom field settings.
|
Initializes the AssetReturnForm with initial values and custom field settings.
|
||||||
"""
|
"""
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields["return_date"].initial = date.today()
|
self.fields["return_date"].widget.attrs.update({"required": "true"})
|
||||||
|
|
||||||
self.fields["return_images"] = MultipleFileField(
|
self.fields["return_images"] = MultipleFileField(
|
||||||
label=_("Return Condition Images")
|
label=_("Return Condition Images")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ class FAQForm(ModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class TicketForm(ModelForm):
|
class TicketForm(ModelForm):
|
||||||
deadline = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Ticket
|
model = Ticket
|
||||||
|
|||||||
@@ -52,9 +52,11 @@ class ConditionForm(forms.ModelForm):
|
|||||||
field.widget.attrs["style"] = (
|
field.widget.attrs["style"] = (
|
||||||
"width:100%; height:50px;border: 1px solid hsl(213deg,22%,84%);border-radius: 0rem;padding: 0.8rem 1.25rem;"
|
"width:100%; height:50px;border: 1px solid hsl(213deg,22%,84%);border-radius: 0rem;padding: 0.8rem 1.25rem;"
|
||||||
)
|
)
|
||||||
elif isinstance(widget, (forms.DateInput)):
|
elif isinstance(widget, forms.DateInput):
|
||||||
field.widget.attrs.update({"class": "oh-input w-100"})
|
field.initial = date.today
|
||||||
field.initial = date.today()
|
widget.input_type = "date"
|
||||||
|
widget.format = "%Y-%m-%d"
|
||||||
|
field.input_formats = ["%Y-%m-%d"]
|
||||||
|
|
||||||
elif isinstance(
|
elif isinstance(
|
||||||
widget, (forms.NumberInput, forms.EmailInput, forms.TextInput)
|
widget, (forms.NumberInput, forms.EmailInput, forms.TextInput)
|
||||||
@@ -115,7 +117,6 @@ class LeaveTypeForm(ConditionForm):
|
|||||||
"color": TextInput(attrs={"type": "color", "style": "height:40px;"}),
|
"color": TextInput(attrs={"type": "color", "style": "height:40px;"}),
|
||||||
"period_in": forms.HiddenInput(),
|
"period_in": forms.HiddenInput(),
|
||||||
"total_days": forms.HiddenInput(),
|
"total_days": forms.HiddenInput(),
|
||||||
"carryforward_expire_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
@@ -179,7 +180,6 @@ class UpdateLeaveTypeForm(ConditionForm):
|
|||||||
"color": TextInput(attrs={"type": "color", "style": "height:40px;"}),
|
"color": TextInput(attrs={"type": "color", "style": "height:40px;"}),
|
||||||
"period_in": forms.HiddenInput(),
|
"period_in": forms.HiddenInput(),
|
||||||
"total_days": forms.HiddenInput(),
|
"total_days": forms.HiddenInput(),
|
||||||
"carryforward_expire_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
@@ -200,8 +200,6 @@ class UpdateLeaveTypeForm(ConditionForm):
|
|||||||
|
|
||||||
|
|
||||||
class LeaveRequestCreationForm(BaseModelForm):
|
class LeaveRequestCreationForm(BaseModelForm):
|
||||||
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
@@ -256,8 +254,6 @@ class LeaveRequestCreationForm(BaseModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class LeaveRequestUpdationForm(BaseModelForm):
|
class LeaveRequestUpdationForm(BaseModelForm):
|
||||||
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
@@ -416,8 +412,6 @@ class AvailableLeaveUpdateForm(BaseModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class UserLeaveRequestForm(BaseModelForm):
|
class UserLeaveRequestForm(BaseModelForm):
|
||||||
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
description = forms.CharField(label=_("Description"), widget=forms.Textarea)
|
description = forms.CharField(label=_("Description"), widget=forms.Textarea)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@@ -537,8 +531,6 @@ class RejectForm(forms.Form):
|
|||||||
|
|
||||||
|
|
||||||
class UserLeaveRequestCreationForm(BaseModelForm):
|
class UserLeaveRequestCreationForm(BaseModelForm):
|
||||||
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
|
||||||
|
|
||||||
def as_p(self, *args, **kwargs):
|
def as_p(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
@@ -875,12 +867,6 @@ class RestrictLeaveForm(BaseModelForm):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(RestrictLeaveForm, self).__init__(*args, **kwargs)
|
super(RestrictLeaveForm, self).__init__(*args, **kwargs)
|
||||||
self.fields["title"].widget.attrs["autocomplete"] = "title"
|
self.fields["title"].widget.attrs["autocomplete"] = "title"
|
||||||
self.fields["start_date"].widget = forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
)
|
|
||||||
self.fields["end_date"].widget = forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
)
|
|
||||||
self.fields["department"].widget.attrs.update(
|
self.fields["department"].widget.attrs.update(
|
||||||
{
|
{
|
||||||
"hx-include": "#leaveRestrictForm",
|
"hx-include": "#leaveRestrictForm",
|
||||||
|
|||||||
@@ -80,10 +80,6 @@ class OffboardingEmployeeForm(ModelForm):
|
|||||||
model = OffboardingEmployee
|
model = OffboardingEmployee
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
exclude = ["notice_period", "unit", "is_active"]
|
exclude = ["notice_period", "unit", "is_active"]
|
||||||
widgets = {
|
|
||||||
"notice_period_starts": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"notice_period_ends": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
}
|
|
||||||
|
|
||||||
def as_p(self):
|
def as_p(self):
|
||||||
"""
|
"""
|
||||||
@@ -254,9 +250,6 @@ class ResignationLetterForm(ModelForm):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields["planned_to_leave_on"].widget = forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
)
|
|
||||||
exclude = []
|
exclude = []
|
||||||
if self.instance.pk:
|
if self.instance.pk:
|
||||||
exclude.append("employee_id")
|
exclude.append("employee_id")
|
||||||
|
|||||||
@@ -848,10 +848,6 @@ class ReimbursementForm(ModelForm):
|
|||||||
"onchange"
|
"onchange"
|
||||||
] = "getAssignedLeave($(this))"
|
] = "getAssignedLeave($(this))"
|
||||||
|
|
||||||
self.fields["allowance_on"].widget = forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.fields["attachment"] = MultipleFileField(label="Attachments")
|
self.fields["attachment"] = MultipleFileField(label="Attachments")
|
||||||
self.fields["attachment"].widget.attrs["accept"] = ".jpg, .jpeg, .png, .pdf"
|
self.fields["attachment"].widget.attrs["accept"] = ".jpg, .jpeg, .png, .pdf"
|
||||||
|
|
||||||
|
|||||||
@@ -47,20 +47,6 @@ class ContractForm(ModelForm):
|
|||||||
self.fields["employee_id"].widget.attrs.update(
|
self.fields["employee_id"].widget.attrs.update(
|
||||||
{"onchange": "contractInitial(this)"}
|
{"onchange": "contractInitial(this)"}
|
||||||
)
|
)
|
||||||
self.fields["contract_start_date"].widget = widgets.DateInput(
|
|
||||||
attrs={
|
|
||||||
"type": "date",
|
|
||||||
"class": "oh-input w-100",
|
|
||||||
"placeholder": "Select a date",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
self.fields["contract_end_date"].widget = widgets.DateInput(
|
|
||||||
attrs={
|
|
||||||
"type": "date",
|
|
||||||
"class": "oh-input w-100",
|
|
||||||
"placeholder": "Select a date",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
self.fields["contract_status"].widget.attrs.update(
|
self.fields["contract_status"].widget.attrs.update(
|
||||||
{
|
{
|
||||||
"class": "oh-select",
|
"class": "oh-select",
|
||||||
|
|||||||
39
pms/forms.py
39
pms/forms.py
@@ -413,17 +413,6 @@ class EmployeeKeyResultForm(BaseForm):
|
|||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
"employee_objective_id": forms.HiddenInput(),
|
"employee_objective_id": forms.HiddenInput(),
|
||||||
"start_date": forms.DateInput(
|
|
||||||
attrs={
|
|
||||||
"class": "oh-input w-100",
|
|
||||||
"type": "date",
|
|
||||||
"required": True,
|
|
||||||
"onchange": "startDateChange()",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"end_date": forms.DateInput(
|
|
||||||
attrs={"class": "oh-input w-100", "type": "date"}
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def as_p(self):
|
def as_p(self):
|
||||||
@@ -437,6 +426,7 @@ class EmployeeKeyResultForm(BaseForm):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
request = getattr(horilla_middlewares._thread_locals, "request", None)
|
request = getattr(horilla_middlewares._thread_locals, "request", None)
|
||||||
|
self.fields["start_date"].widget.attrs.update({"onchange": "startDateChange()"})
|
||||||
if self.initial.get("employee_objective_id"):
|
if self.initial.get("employee_objective_id"):
|
||||||
if (
|
if (
|
||||||
type(self.initial.get("employee_objective_id")) == int
|
type(self.initial.get("employee_objective_id")) == int
|
||||||
@@ -580,12 +570,6 @@ class KeyResultForm(ModelForm):
|
|||||||
"target_value": forms.NumberInput(
|
"target_value": forms.NumberInput(
|
||||||
attrs={"class": "oh-input w-100", "required": True}
|
attrs={"class": "oh-input w-100", "required": True}
|
||||||
),
|
),
|
||||||
"start_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100", "required": True}
|
|
||||||
),
|
|
||||||
"end_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100", "required": True}
|
|
||||||
),
|
|
||||||
"progress_type": forms.Select(
|
"progress_type": forms.Select(
|
||||||
attrs={
|
attrs={
|
||||||
"class": "oh-select oh-select--lg oh-select-no-search w-100",
|
"class": "oh-select oh-select--lg oh-select-no-search w-100",
|
||||||
@@ -691,12 +675,6 @@ class FeedbackForm(HorillaModelForm):
|
|||||||
"review_cycle": forms.TextInput(
|
"review_cycle": forms.TextInput(
|
||||||
attrs={"placeholder": _("Enter a title"), "class": "oh-input w-100"}
|
attrs={"placeholder": _("Enter a title"), "class": "oh-input w-100"}
|
||||||
),
|
),
|
||||||
"start_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
),
|
|
||||||
"end_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
),
|
|
||||||
"cyclic_feedback": forms.CheckboxInput(
|
"cyclic_feedback": forms.CheckboxInput(
|
||||||
attrs={
|
attrs={
|
||||||
"class": "oh-switch__checkbox",
|
"class": "oh-switch__checkbox",
|
||||||
@@ -958,7 +936,7 @@ class ObjectiveCommentForm(ModelForm):
|
|||||||
reload_queryset(self.fields)
|
reload_queryset(self.fields)
|
||||||
|
|
||||||
|
|
||||||
class PeriodForm(ModelForm):
|
class PeriodForm(HorillaModelForm):
|
||||||
"""
|
"""
|
||||||
A form for creating or updating a Period object.
|
A form for creating or updating a Period object.
|
||||||
"""
|
"""
|
||||||
@@ -975,12 +953,6 @@ class PeriodForm(ModelForm):
|
|||||||
"period_name": forms.TextInput(
|
"period_name": forms.TextInput(
|
||||||
attrs={"placeholder": "Q1.", "class": "oh-input w-100"}
|
attrs={"placeholder": "Q1.", "class": "oh-input w-100"}
|
||||||
),
|
),
|
||||||
"start_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
),
|
|
||||||
"end_date": forms.DateInput(
|
|
||||||
attrs={"type": "date", "class": "oh-input w-100"}
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@@ -1024,8 +996,13 @@ class AnonymousFeedbackForm(BaseForm):
|
|||||||
class MeetingsForm(BaseForm):
|
class MeetingsForm(BaseForm):
|
||||||
date = forms.DateTimeField(
|
date = forms.DateTimeField(
|
||||||
widget=forms.DateTimeInput(
|
widget=forms.DateTimeInput(
|
||||||
attrs={"class": "oh-input w-100", "type": "datetime-local"}
|
format="%Y-%m-%dT%H:%M",
|
||||||
|
attrs={
|
||||||
|
"class": "oh-input w-100",
|
||||||
|
"type": "datetime-local",
|
||||||
|
},
|
||||||
),
|
),
|
||||||
|
input_formats=["%Y-%m-%dT%H:%M"],
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ class ProjectForm(ModelForm):
|
|||||||
|
|
||||||
model = Project
|
model = Project
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
widgets = {
|
|
||||||
"start_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"end_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ProjectTimeSheetForm(ModelForm):
|
class ProjectTimeSheetForm(ModelForm):
|
||||||
@@ -59,10 +55,6 @@ class ProjectTimeSheetForm(ModelForm):
|
|||||||
|
|
||||||
model = Project
|
model = Project
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
widgets = {
|
|
||||||
"start_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"end_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class TaskForm(ModelForm):
|
class TaskForm(ModelForm):
|
||||||
@@ -80,7 +72,6 @@ class TaskForm(ModelForm):
|
|||||||
# exclude = ("project_id",)
|
# exclude = ("project_id",)
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
"end_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"project": forms.HiddenInput(),
|
"project": forms.HiddenInput(),
|
||||||
"stage": forms.HiddenInput(),
|
"stage": forms.HiddenInput(),
|
||||||
"sequence": forms.HiddenInput(),
|
"sequence": forms.HiddenInput(),
|
||||||
@@ -121,7 +112,6 @@ class TaskFormCreate(ModelForm):
|
|||||||
# exclude = ("project_id",)
|
# exclude = ("project_id",)
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
"end_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"project": forms.HiddenInput(),
|
"project": forms.HiddenInput(),
|
||||||
"sequence": forms.HiddenInput(),
|
"sequence": forms.HiddenInput(),
|
||||||
"stage": forms.SelectMultiple(
|
"stage": forms.SelectMultiple(
|
||||||
@@ -163,8 +153,6 @@ class TaskAllForm(ModelForm):
|
|||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
"start_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"end_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"sequence": forms.HiddenInput(),
|
"sequence": forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,9 +214,6 @@ class TimeSheetForm(ModelForm):
|
|||||||
|
|
||||||
model = TimeSheet
|
model = TimeSheet
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
widgets = {
|
|
||||||
"date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, *args, request=None, **kwargs):
|
def __init__(self, *args, request=None, **kwargs):
|
||||||
super(TimeSheetForm, self).__init__(*args, **kwargs)
|
super(TimeSheetForm, self).__init__(*args, **kwargs)
|
||||||
@@ -274,7 +259,6 @@ class TimesheetInTaskForm(ModelForm):
|
|||||||
model = TimeSheet
|
model = TimeSheet
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
widgets = {
|
widgets = {
|
||||||
"date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"project_id": forms.HiddenInput(),
|
"project_id": forms.HiddenInput(),
|
||||||
"task_id": forms.HiddenInput(),
|
"task_id": forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
@@ -314,7 +298,6 @@ class TaskTimeSheetForm(ModelForm):
|
|||||||
model = Task
|
model = Task
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
widgets = {
|
widgets = {
|
||||||
"end_date": forms.DateInput(attrs={"type": "date"}),
|
|
||||||
"project": forms.HiddenInput(),
|
"project": forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user