Skip to content

Commit

Permalink
Merge branch 'v12-pre-release' into version-12
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil28297 committed Jan 16, 2020
2 parents 8007d59 + 70385c8 commit 3dc3bd2
Show file tree
Hide file tree
Showing 69 changed files with 660 additions and 1,483 deletions.
21 changes: 12 additions & 9 deletions cypress/integration/form.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
context('Form', () => {
beforeEach(() => {
cy.login();
cy.visit('/desk');
});
before(() => {
cy.login();
cy.visit('/desk');
cy.window().its('frappe').then(frappe => {
frappe.call("frappe.tests.ui_test_helpers.create_contact_records");
});
});
beforeEach(() => {
cy.visit('/desk');
});
it('create a new form', () => {
cy.visit('/desk#Form/ToDo/New ToDo 1');
cy.fill_field('description', 'this is a test todo', 'Text Editor').blur();
Expand All @@ -27,13 +26,17 @@ context('Form', () => {
cy.get('.filter-field .input-with-feedback.form-control').type('123', { force: true });
cy.get('.filter-box .btn:contains("Apply")').click({ force: true });
cy.visit('/desk#Form/Contact/Test Form Contact 3');
cy.get('.prev-doc').click();
cy.get('.prev-doc').should('be.visible').click();
cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible');
cy.get('.modal-backdrop').click();
cy.get('.next-doc').click();
cy.get('.btn-modal-close:visible').click();
cy.get('.next-doc').click({ force: true });
cy.wait(200);
cy.contains('Test Form Contact 2').should('not.exist');
cy.get('.page-title .title-text').should('contain', 'Test Form Contact 1');
cy.visit('/desk#List/Contact');
cy.get('.clear-filters.btn').click();
// clear filters
cy.window().its('frappe').then((frappe) => {
let list_view = frappe.get_list_view('Contact');
list_view.filter_area.filter_list.clear_filters();
});
});
});
2 changes: 1 addition & 1 deletion frappe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
reload(sys)
sys.setdefaultencoding("utf-8")

__version__ = '12.1.0'
__version__ = '12.2.0'
__title__ = "Frappe Framework"

local = Local()
Expand Down
37 changes: 21 additions & 16 deletions frappe/automation/doctype/auto_repeat/auto_repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from frappe.utils.jinja import validate_template
from dateutil.relativedelta import relativedelta
from frappe.utils.user import get_system_managers
from frappe.utils import cstr, getdate, split_emails, add_days, today, get_last_day, get_first_day
from frappe.utils import cstr, getdate, split_emails, add_days, today, get_last_day, get_first_day, month_diff
from frappe.model.document import Document
from frappe.core.doctype.communication.email import make
from frappe.utils.background_jobs import get_jobs
Expand Down Expand Up @@ -48,7 +48,7 @@ def set_dates(self):
if self.disabled:
self.next_schedule_date = None
else:
self.next_schedule_date = get_next_schedule_date(self.start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day, self.end_date)
self.next_schedule_date = get_next_schedule_date(self.start_date, self.frequency, self.start_date, self.repeat_on_day, self.repeat_on_last_day, self.end_date)

def unlink_if_applicable(self):
if self.status == 'Completed' or self.disabled:
Expand Down Expand Up @@ -107,27 +107,27 @@ def get_auto_repeat_schedule(self):
end_date = getdate(self.end_date)

if not self.end_date:
start_date = get_next_schedule_date(start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day)
next_date = get_next_schedule_date(start_date, self.frequency, self.start_date, self.repeat_on_day, self.repeat_on_last_day)
row = {
"reference_document": self.reference_document,
"frequency": self.frequency,
"next_scheduled_date": start_date
"next_scheduled_date": next_date
}
schedule_details.append(row)
start_date = get_next_schedule_date(start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day)

if self.end_date:
start_date = get_next_schedule_date(
start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day, for_full_schedule=True)
while (getdate(start_date) < getdate(end_date)):
next_date = get_next_schedule_date(
start_date, self.frequency, self.start_date, self.repeat_on_day, self.repeat_on_last_day, for_full_schedule=True)

while (getdate(next_date) < getdate(end_date)):
row = {
"reference_document" : self.reference_document,
"frequency" : self.frequency,
"next_scheduled_date" : start_date
"next_scheduled_date" : next_date
}
schedule_details.append(row)
start_date = get_next_schedule_date(
start_date, self.frequency, self.repeat_on_day, self.repeat_on_last_day, end_date, for_full_schedule=True)
next_date = get_next_schedule_date(
next_date, self.frequency, self.start_date, self.repeat_on_day, self.repeat_on_last_day, end_date, for_full_schedule=True)

return schedule_details

Expand Down Expand Up @@ -268,8 +268,12 @@ def notify_error_to_user(self, error_log):
)


def get_next_schedule_date(start_date, frequency, repeat_on_day, repeat_on_last_day = False, end_date = None, for_full_schedule=False):
month_count = month_map.get(frequency)
def get_next_schedule_date(schedule_date, frequency, start_date, repeat_on_day=None, repeat_on_last_day=False, end_date=None, for_full_schedule=False):
if month_map.get(frequency):
month_count = month_map.get(frequency) + month_diff(schedule_date, start_date) - 1
else:
month_count = 0

day_count = 0
if month_count and repeat_on_last_day:
next_date = get_next_date(start_date, month_count, 31)
Expand All @@ -288,7 +292,9 @@ def get_next_schedule_date(start_date, frequency, repeat_on_day, repeat_on_last_
# next schedule date should be after or on current date
if not for_full_schedule:
while getdate(next_date) < getdate(today()):
next_date = get_next_date(next_date, month_count, day_count)
if month_count:
month_count += month_map.get(frequency)
next_date = get_next_date(start_date, month_count, day_count)

return next_date

Expand Down Expand Up @@ -316,8 +322,7 @@ def create_repeated_entries(data):

if schedule_date == current_date and not doc.disabled:
doc.create_documents()
schedule_date = get_next_schedule_date(schedule_date, doc.frequency, doc.repeat_on_day, doc.repeat_on_last_day, doc.end_date)

schedule_date = get_next_schedule_date(schedule_date, doc.frequency, doc.start_date, doc.repeat_on_day, doc.repeat_on_last_day, doc.end_date)
if schedule_date and not doc.disabled:
frappe.db.set_value('Auto Repeat', doc.name, 'next_schedule_date', schedule_date)

Expand Down
43 changes: 43 additions & 0 deletions frappe/cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,46 @@ def get_doctype_map(doctype, name, filters, order_by=None):
def clear_doctype_map(doctype, name):
cache_key = frappe.scrub(doctype) + '_map'
frappe.cache().hdel(cache_key, name)

def build_table_count_cache():
if frappe.flags.in_patch or frappe.flags.in_install or frappe.flags.in_import:
return
_cache = frappe.cache()
data = frappe.db.multisql({
"mariadb": """
SELECT table_name AS name,
table_rows AS count
FROM information_schema.tables""",
"postgres": """
SELECT "relname" AS name,
"n_tup_ins" AS count
FROM "pg_stat_all_tables"
"""
}, as_dict=1)

counts = {d.get('name').lstrip('tab'): d.get('count', None) for d in data}
_cache.set_value("information_schema:counts", counts)

return counts

def build_domain_restriced_doctype_cache():
if frappe.flags.in_patch or frappe.flags.in_install or frappe.flags.in_import:
return
_cache = frappe.cache()
active_domains = frappe.get_active_domains()
doctypes = frappe.get_all("DocType", filters={'restrict_to_domain': ('IN', active_domains)})
doctypes = [doc.name for doc in doctypes]
_cache.set_value("domain_restricted_doctypes", doctypes)

return doctypes

def build_domain_restriced_page_cache():
if frappe.flags.in_patch or frappe.flags.in_install or frappe.flags.in_import:
return
_cache = frappe.cache()
active_domains = frappe.get_active_domains()
pages = frappe.get_all("Page", filters={'restrict_to_domain': ('IN', active_domains)})
pages = [page.name for page in pages]
_cache.set_value("domain_restricted_pages", pages)

return pages
24 changes: 24 additions & 0 deletions frappe/change_log/v12/v12_2_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Version 12.2.0 Release Notes

- Fixed grid empty row validation ([#9045](https://github.com/frappe/frappe/pull/9045))
- Add default email account required for email linking ([#9021](https://github.com/frappe/frappe/pull/9021))
- Treat html editor as data field in standard filter ([#9123](https://github.com/frappe/frappe/pull/9123))
- Whitelist schema.org attributes ([#9125](https://github.com/frappe/frappe/pull/9125))
- Fixed auto repeat. Derive next date from start date and offset ([#9178](https://github.com/frappe/frappe/pull/9178))
- Fixed bug in show/hide global cards ([#9165](https://github.com/frappe/frappe/pull/]9165) ))
- Fixed validation for email in standard filters ([#9048](https://github.com/frappe/frappe/pull/9048))
- Child Table Update in New Data Import ([#9131](https://github.com/frappe/frappe/pull/9131))
- Formatting for check in print view ([#9147](https://github.com/frappe/frappe/pull/9147))
- Fixed error while trying to print PDFs ([#9134](https://github.com/frappe/frappe/pull/9134))
- Allowed tables to be sent with dates in webhook ([#9171](https://github.com/frappe/frappe/pull/9171))
- Fixed file duplicate check ([#9162](https://github.com/frappe/frappe/pull/9162))
- (Re)allowed custom filters/methods to be used with jinja ([#9156](https://github.com/frappe/frappe/pull/9156))
- Ignored Tag Link validation in Report ([#8928](https://github.com/frappe/frappe/pull/8928))
- Persist scope search in search page ([#9207](https://github.com/frappe/frappe/pull/9207))
- Allowed multiple webhooks for identical doctype triggers ([#9208](https://github.com/frappe/frappe/pull/9208))
- Load latest custom report instead of latest reference report ([#9192](https://github.com/frappe/frappe/pull/9192))
- Allow Kanban creation with column data in list view ([#9211](https://github.com/frappe/frappe/pull/9211))
- Fixed custom report load ([#9221](https://github.com/frappe/frappe/pull/9221))
- Ability to add fields to quick entry ([#9146](https://github.com/frappe/frappe/pull/9146))
- Made email parsing rfc5322 compliant for python3 ([#9056](https://github.com/frappe/frappe/pull/9056))
- Fixed email sending & receiving issues ([#9202](https://github.com/frappe/frappe/pull/9202)), ([#9158](https://github.com/frappe/frappe/pull/9158)), ([#9155](https://github.com/frappe/frappe/pull/9155)), ([#9190](https://github.com/frappe/frappe/pull/9190))
9 changes: 9 additions & 0 deletions frappe/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,15 @@ def run_tests(context, app=None, module=None, doctype=None, test=(),
tests = test

site = get_site(context)

allow_tests = frappe.get_conf(site).allow_tests

if not (allow_tests or os.environ.get('CI')):
click.secho('Testing is disabled for the site!', bold=True)
click.secho('You can enable tests by entering following command:')
click.secho('bench --site {0} set-config allow_tests true'.format(site), fg='green')
return

frappe.init(site=site)

frappe.flags.skip_before_tests = skip_before_tests
Expand Down
30 changes: 20 additions & 10 deletions frappe/core/doctype/communication/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,26 @@ def get_contacts(email_strings):
email = get_email_without_link(email)
contact_name = get_contact_name(email)

if not contact_name:
contact = frappe.get_doc({
"doctype": "Contact",
"first_name": frappe.unscrub(email.split("@")[0]),
})
contact.add_email(email_id=email, is_primary=True)
contact.insert(ignore_permissions=True)
contact_name = contact.name

contacts.append(contact_name)
if not contact_name and email:
email_parts = email.split("@")
first_name = frappe.unscrub(email_parts[0])

try:
contact_name = '{0}-{1}'.format(first_name, email_parts[1]) if first_name == 'Contact' else first_name
contact = frappe.get_doc({
"doctype": "Contact",
"first_name": contact_name,
"name": contact_name
})
contact.add_email(email_id=email, is_primary=True)
contact.insert(ignore_permissions=True)
contact_name = contact.name
except Exception:
traceback = frappe.get_traceback()
frappe.log_error(traceback)

if contact_name:
contacts.append(contact_name)

return contacts

Expand Down
Loading

0 comments on commit 3dc3bd2

Please sign in to comment.