Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: created by field in doctypes for export (#113) #121

Merged
merged 5 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
"column_break_40",
"employment_type",
"other_employment_type",
"section_break_vzck",
"created_by",
"section_break_uwdz",
"bottom_save_button"
],
Expand Down Expand Up @@ -86,6 +88,7 @@
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Ward/GP",
"length": 600,
"options": "Ward"
},
{
Expand Down Expand Up @@ -361,6 +364,16 @@
"fieldtype": "Table MultiSelect",
"label": "Languages Known",
"options": "Language Multiselect"
},
{
"fieldname": "section_break_vzck",
"fieldtype": "Section Break"
},
{
"fieldname": "created_by",
"fieldtype": "Data",
"label": "Created By",
"read_only": 1
}
],
"image_field": "image",
Expand All @@ -387,7 +400,7 @@
"link_fieldname": "beneficiary"
}
],
"modified": "2023-08-22 10:28:30.184399",
"modified": "2023-09-05 17:03:01.300560",
"modified_by": "Administrator",
"module": "Frappe Changemakers",
"name": "Beneficiary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@


class Beneficiary(Document):
def before_save(self):
self.set_created_by()

def validate(self):
self.validate_age()
self.validate_phone_number_fields()
Expand All @@ -24,3 +27,7 @@ def validate_phone_number_fields(self):

if self.phone_number and not is_valid_indian_phone_number(self.phone_number):
frappe.throw(f"Value of {frappe.bold('Phone')} is not a valid Indian Phone number")

def set_created_by(self):
if not self.created_by:
self.created_by = self.owner
19 changes: 18 additions & 1 deletion changemakers/frappe_changemakers/doctype/case/case.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"follow_up_details_section",
"family_meeting_outcome",
"followups",
"data_cjaa",
"section_break_seoz",
"created_by",
"section_break_yuho",
"bottom_save_button",
"column_break_qfjk"
Expand Down Expand Up @@ -310,11 +313,25 @@
{
"fieldname": "section_break_ajqf",
"fieldtype": "Section Break"
},
{
"fieldname": "data_cjaa",
"fieldtype": "Data"
},
{
"fieldname": "section_break_seoz",
"fieldtype": "Section Break"
},
{
"fieldname": "created_by",
"fieldtype": "Data",
"label": "Created By",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-07-08 01:09:06.876317",
"modified": "2023-09-05 17:04:47.689828",
"modified_by": "Administrator",
"module": "Frappe Changemakers",
"name": "Case",
Expand Down
7 changes: 6 additions & 1 deletion changemakers/frappe_changemakers/doctype/case/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@


class Case(Document):
pass
def before_save(self):
self.set_created_by()

def set_created_by(self):
if not self.created_by:
self.created_by = self.owner
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"field_order": [
"beneficiary",
"date",
"daily_update"
"daily_update",
"section_break_naow",
"created_by"
],
"fields": [
{
Expand All @@ -36,11 +38,21 @@
"fieldtype": "Text",
"in_list_view": 1,
"label": "Daily Update"
},
{
"fieldname": "section_break_naow",
"fieldtype": "Section Break"
},
{
"fieldname": "created_by",
"fieldtype": "Data",
"label": "Created by",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-07-16 16:25:54.521737",
"modified": "2023-09-05 17:11:41.703890",
"modified_by": "Administrator",
"module": "Frappe Changemakers",
"name": "Daily Visit Update",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ class DailyVisitUpdate(Document):
def before_naming(self):
if not self.date:
self.date = today()

def before_save(self):
self.set_created_by()

def set_created_by(self):
if not self.created_by:
self.created_by = self.owner
14 changes: 13 additions & 1 deletion changemakers/frappe_changemakers/doctype/rescue/rescue.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"police_memo",
"section_break_zcfc",
"other_remarks",
"section_break_ubix",
"created_by",
"section_break_vjqi",
"bottom_save_button",
"amended_from",
Expand Down Expand Up @@ -273,12 +275,22 @@
"fieldname": "bottom_save_button",
"fieldtype": "Button",
"label": "Save"
},
{
"fieldname": "section_break_ubix",
"fieldtype": "Section Break"
},
{
"fieldname": "created_by",
"fieldtype": "Data",
"label": "Created by",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-03-05 11:31:01.409990",
"modified": "2023-09-05 17:08:57.368937",
"modified_by": "Administrator",
"module": "Frappe Changemakers",
"name": "Rescue",
Expand Down
7 changes: 7 additions & 0 deletions changemakers/frappe_changemakers/doctype/rescue/rescue.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ def validate(self):
self.validate_remarks_length()
self.set_location_coordinates()

def before_save(self):
self.set_created_by()

def set_created_by(self):
if not self.created_by:
self.created_by = self.owner

def validate_remarks_length(self):
if self.other_remarks and len(self.other_remarks) > 300:
frappe.throw("Other remarks cannot be more than 300 characters long.")
Expand Down
Loading