Skip to content

Commit

Permalink
Merge branch 'develop' into txt-attachment-privacy
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Mar 15, 2024
2 parents c2638d9 + b6f65ea commit aa51492
Show file tree
Hide file tree
Showing 185 changed files with 45,117 additions and 3,383 deletions.
37 changes: 37 additions & 0 deletions .github/helper/update_pot_file.sh
@@ -0,0 +1,37 @@
#!/bin/bash
set -e
cd ~ || exit

echo "Setting Up Bench..."

pip install frappe-bench
bench -v init frappe-bench --skip-assets --skip-redis-config-generation --python "$(which python)" --frappe-path "${GITHUB_WORKSPACE}"
cd ./frappe-bench || exit

echo "Generating POT file..."
bench generate-pot-file --app frappe

cd ./apps/frappe || exit

echo "Configuring git user..."
git config user.email "developers@erpnext.com"
git config user.name "frappe-pr-bot"

echo "Setting the correct git remote..."
# Here, the git remote is a local file path by default. Let's change it to the upstream repo.
git remote set-url upstream https://github.com/frappe/frappe.git

echo "Creating a new branch..."
isodate=$(date -u +"%Y-%m-%d")
branch_name="pot_${BASE_BRANCH}_${isodate}"
git checkout -b "${branch_name}"

echo "Commiting changes..."
git add .
git commit -m "chore: update POT file"

gh auth setup-git
git push -u upstream "${branch_name}"

echo "Creating a PR..."
gh pr create --fill --base "${BASE_BRANCH}" --head "${branch_name}" -R frappe/frappe
38 changes: 38 additions & 0 deletions .github/workflows/generate-pot-file.yml
@@ -0,0 +1,38 @@
# This workflow is agnostic to branches. Only maintain on develop branch.
# To add/remove branches just modify the matrix.

name: Regenerate POT file (translatable strings)
on:
schedule:
# 9:30 UTC => 3 PM IST Sunday
- cron: "30 9 * * 0"
workflow_dispatch:

jobs:
regeneratee-pot-file:
name: Release
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch: ["develop"]
permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Run script to update POT file
run: |
bash ${GITHUB_WORKSPACE}/.github/helper/update_pot_file.sh
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
BASE_BRANCH: ${{ matrix.branch }}
6 changes: 5 additions & 1 deletion .github/workflows/server-tests.yml
Expand Up @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
needs: checkrun
if: ${{ needs.checkrun.outputs.build == 'strawberry' }}
timeout-minutes: 60
timeout-minutes: 30
env:
NODE_ENV: "production"

Expand Down Expand Up @@ -160,6 +160,10 @@ jobs:
cat $f
done
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ contains( github.event.pull_request.labels.*.name, 'debug-gha') }}

- name: Upload coverage data
uses: actions/upload-artifact@v3
if: github.event_name != 'pull_request'
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -2,7 +2,6 @@
*.py~
*.comp.js
*.DS_Store
locale
.wnf-lang-status
*.swp
*.egg-info
Expand Down
6 changes: 5 additions & 1 deletion crowdin.yml
@@ -1,4 +1,8 @@
files:
- source: /frappe/locale/main.pot
translation: /frappe/locale/%two_letters_code%.po
pull_request_title: "chore: sync translations from crowdin"
pull_request_title: "fix: sync translations from crowdin"
pull_request_labels:
- translation
commit_message: "fix: %language% translations"
append_commit_message: false
15 changes: 14 additions & 1 deletion cypress.config.js
@@ -1,4 +1,5 @@
const { defineConfig } = require("cypress");
const fs = require("fs");

module.exports = defineConfig({
projectId: "92odwv",
Expand All @@ -7,7 +8,6 @@ module.exports = defineConfig({
defaultCommandTimeout: 20000,
pageLoadTimeout: 15000,
video: true,
videoUploadOnPasses: false,
viewportHeight: 960,
viewportWidth: 1400,
retries: {
Expand All @@ -18,6 +18,19 @@ module.exports = defineConfig({
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
// Delete videos for specs without failing or retried tests
// https://docs.cypress.io/guides/guides/screenshots-and-videos#Delete-videos-for-specs-without-failing-or-retried-tests
on("after:spec", (spec, results) => {
if (results && results.video) {
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === "failed")
);
if (!failures) {
fs.unlinkSync(results.video);
}
}
});

return require("./cypress/plugins/index.js")(on, config);
},
testIsolation: false,
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/list_paging.js
Expand Up @@ -37,6 +37,6 @@ context("List Paging", () => {
cy.get(".list-paging-area .list-count").should("contain.text", "500 of");
cy.get(".list-paging-area .btn-more").click();

cy.get(".list-paging-area .list-count").should("contain.text", "1000 of");
cy.get(".list-paging-area .list-count").should("contain.text", "1,000 of");
});
});
2 changes: 1 addition & 1 deletion esbuild/esbuild.js
Expand Up @@ -156,7 +156,7 @@ async function update_assets_json_from_built_assets(apps) {

async function update_assets_obj(app, assets, assets_rtl) {
const app_path = path.join(apps_path, app, app);
const dist_path = path.join(app_path, "public, dist");
const dist_path = path.join(app_path, "public", "dist");
const files = await glob("**/*.bundle.*.{js,css}", { cwd: dist_path });
const prefix = path.join("/", "assets", app, "dist");

Expand Down
59 changes: 36 additions & 23 deletions frappe/__init__.py
Expand Up @@ -504,9 +504,9 @@ def setup_redis_cache_connection():
global cache

if not cache:
from frappe.utils.redis_wrapper import RedisWrapper
from frappe.utils.redis_wrapper import setup_cache

cache = RedisWrapper.from_url(conf.get("redis_cache"))
cache = setup_cache()


def get_traceback(with_context: bool = False) -> str:
Expand Down Expand Up @@ -536,8 +536,7 @@ def log(msg: str) -> None:
:param msg: Message."""
if not request:
if conf.get("logging"):
print(repr(msg))
print(repr(msg))

debug_log.append(as_unicode(msg))

Expand Down Expand Up @@ -1699,11 +1698,19 @@ def append_hook(target, key, value):
target[key].extend(value)


def setup_module_map(include_all_apps=True):
"""Rebuild map of all modules (internal)."""
if conf.db_name:
def setup_module_map(include_all_apps: bool = True) -> None:
"""
Function to rebuild map of all modules
:param: include_all_apps: Include all apps on bench, or just apps installed on the site.
:return: Nothing
"""
if include_all_apps:
local.app_modules = cache.get_value("app_modules")
local.module_app = cache.get_value("module_app")
else:
local.app_modules = cache.get_value("installed_app_modules")
local.module_app = cache.get_value("module_installed_app")

if not (local.app_modules and local.module_app):
local.module_app, local.app_modules = {}, {}
Expand All @@ -1722,9 +1729,12 @@ def setup_module_map(include_all_apps=True):
local.module_app[module] = app
local.app_modules[app].append(module)

if conf.db_name:
if include_all_apps:
cache.set_value("app_modules", local.app_modules)
cache.set_value("module_app", local.module_app)
else:
cache.set_value("installed_app_modules", local.app_modules)
cache.set_value("module_installed_app", local.module_app)


def get_file_items(path, raise_not_found=False, ignore_empty_lines=True):
Expand Down Expand Up @@ -2178,24 +2188,27 @@ def get_print(
:param as_pdf: Return as PDF. Default False.
:param password: Password to encrypt the pdf with. Default None"""
from frappe.utils.pdf import get_pdf
from frappe.website.serve import get_response_content
from frappe.website.serve import get_response_without_exception_handling

original_form_dict = copy.deepcopy(local.form_dict)
try:
local.form_dict.doctype = doctype
local.form_dict.name = name
local.form_dict.format = print_format
local.form_dict.style = style
local.form_dict.doc = doc
local.form_dict.no_letterhead = no_letterhead
local.form_dict.letterhead = letterhead

pdf_options = pdf_options or {}
if password:
pdf_options["password"] = password

response = get_response_without_exception_handling("printview", 200)
html = str(response.data, "utf-8")
finally:
local.form_dict = original_form_dict

local.form_dict.doctype = doctype
local.form_dict.name = name
local.form_dict.format = print_format
local.form_dict.style = style
local.form_dict.doc = doc
local.form_dict.no_letterhead = no_letterhead
local.form_dict.letterhead = letterhead

pdf_options = pdf_options or {}
if password:
pdf_options["password"] = password

html = get_response_content("printview")
local.form_dict = original_form_dict
return get_pdf(html, options=pdf_options, output=output) if as_pdf else html


Expand Down
19 changes: 8 additions & 11 deletions frappe/app.py
Expand Up @@ -295,14 +295,15 @@ def make_form_dict(request: Request):
args.update(request.args or {})
args.update(request.form or {})

if not isinstance(args, dict):
if isinstance(args, dict):
frappe.local.form_dict = frappe._dict(args)
# _ is passed by $.ajax so that the request is not cached by the browser. So, remove _ from form_dict
frappe.local.form_dict.pop("_", None)
elif isinstance(args, list):
frappe.local.form_dict["data"] = args
else:
frappe.throw(_("Invalid request arguments"))

frappe.local.form_dict = frappe._dict(args)

# _ is passed by $.ajax so that the request is not cached by the browser. So, remove _ from form_dict
frappe.local.form_dict.pop("_", None)


def handle_exception(e):
response = None
Expand Down Expand Up @@ -398,11 +399,7 @@ def handle_exception(e):

def sync_database(rollback: bool) -> bool:
# if HTTP method would change server state, commit if necessary
if (
frappe.db
and (frappe.local.flags.commit or frappe.local.request.method in UNSAFE_HTTP_METHODS)
and frappe.db.transaction_writes
):
if frappe.db and (frappe.local.flags.commit or frappe.local.request.method in UNSAFE_HTTP_METHODS):
frappe.db.commit()
rollback = False
elif frappe.db:
Expand Down
4 changes: 2 additions & 2 deletions frappe/automation/doctype/assignment_rule/assignment_rule.py
Expand Up @@ -31,8 +31,8 @@ class AssignmentRule(Document):
description: DF.SmallText
disabled: DF.Check
document_type: DF.Link
due_date_based_on: DF.Literal
field: DF.Literal
due_date_based_on: DF.Literal[None]
field: DF.Literal[None]
last_user: DF.Link | None
priority: DF.Int
rule: DF.Literal["Round Robin", "Load Balancing", "Based on Field"]
Expand Down
Expand Up @@ -18,7 +18,7 @@ class MilestoneTracker(Document):

disabled: DF.Check
document_type: DF.Link
track_field: DF.Literal
track_field: DF.Literal[None]
# end: auto-generated types

def on_update(self):
Expand Down
2 changes: 2 additions & 0 deletions frappe/cache_manager.py
Expand Up @@ -26,7 +26,9 @@ def get_doctype_map_key(doctype):
"installed_apps",
"all_apps",
"app_modules",
"installed_app_modules",
"module_app",
"module_installed_app",
"system_settings",
"scheduler_events",
"time_zone",
Expand Down
4 changes: 2 additions & 2 deletions frappe/commands/site.py
Expand Up @@ -349,7 +349,7 @@ def partial_restore(context, sql_file_path, verbose, encryption_key=None):
with decrypt_backup(sql_file_path, key):
if not is_partial(sql_file_path):
click.secho(
"Full backup file detected.Use `bench restore` to restore a Frappe Site.",
"Full backup file detected. Use `bench restore` to restore a Frappe Site.",
fg="red",
)
sys.exit(1)
Expand All @@ -364,7 +364,7 @@ def partial_restore(context, sql_file_path, verbose, encryption_key=None):
else:
if not is_partial(sql_file_path):
click.secho(
"Full backup file detected.Use `bench restore` to restore a Frappe Site.",
"Full backup file detected. Use `bench restore` to restore a Frappe Site.",
fg="red",
)
sys.exit(1)
Expand Down

0 comments on commit aa51492

Please sign in to comment.