Skip to content

Commit

Permalink
release 2.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
xjsender committed Apr 2, 2015
1 parent 4dd45b7 commit f9ddd5f
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 7 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Release History
---------------


Release 2.8.3 (2015-04-02)
++++++++++++++++++
* If no CRUD privilege on profile object, just leave blank in the output csv
* Add field FLS export feature, it's a wonderful feature for document


Release 2.8.2 (2015-03-28)
++++++++++++++++++
* Fix package.xml completion bug if file name contains multiple dot
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ If you just want to export some attributes of validation rules, you can remove s
You can click ```HaoIDE``` > ```Export``` > ```Export CustomFields``` to export all custom fields in your org to CSV.

### Export Profile Workbook
You can click ```HaoIDE``` > ```Export``` > ```Export Profile``` to export ```ObjectPermission```, ```TabVisibilities``` and ```UserPermissions``` of all profiles to three different CSV files, see [ObjectPermission CSV Picture](https://raw.githubusercontent.com/xjsender/SublimeApexScreenshot/master/Profile.png)
You can click ```HaoIDE``` > ```Export``` > ```Export Profile``` to export ```ObjectPermission```, ```TabVisibilities```, ```FieldLevelSecurity``` and ```UserPermissions``` of all profiles to three different CSV files, see [ObjectPermission CSV Picture](https://raw.githubusercontent.com/xjsender/SublimeApexScreenshot/master/Profile.png)

Before execute this command, you should execute the ```Retrieve All``` command to download all related components.

Expand Down
11 changes: 11 additions & 0 deletions config/messages/2.8.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Build 2.8.3
-----------
Release Date: 2 Apr 2015

* If no CRUD privilege on profile object, just leave blank in the output csv
* Add field FLS export feature, it's a wonderful feature for document

Notes:

* You should restart your sublime after ``HaoIDE`` is upgraded
-----------
2 changes: 1 addition & 1 deletion config/settings/package.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haoide",
"version": "2.8.2",
"version": "2.8.3",
"description": "haoide is a Sublime Text 3 plugin for Salesforce and used for swift development on Force.com",
"author": "Hao Liu",
"email": "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"2.8.0": "config/messages/2.8.0.md",
"2.8.1": "config/messages/2.8.1.md",
"2.8.2": "config/messages/2.8.2.md",
"2.8.3": "config/messages/2.8.3.md",
"install": "config/messages/install.txt"
}
81 changes: 76 additions & 5 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,7 @@ def export_profile_settings():
profile_settings = {}
sobject_names = []
tab_names = []
sobject_fields = {}
permission_names = []
for profile in profiles:
# Escape profile name, for example,
Expand Down Expand Up @@ -2459,6 +2460,29 @@ def export_profile_settings():
if "recordTypeVisibilities" in result:
pass

# Parsing fieldPermission as {}
if "fieldPermissions" in result:
field_permissions = {}

fps = result["fieldPermissions"];
if isinstance(fps, dict): fps = [fps]

for fp in fps:
# Parse the field
sobject, field = fp["field"].split(".")

# Keep object => [fields] dict
if sobject in sobject_fields:
if field not in sobject_fields[sobject]:
sobject_fields[sobject].append(field)
else:
sobject_fields[sobject] = [field]

# Parse fields to field_permissions
field_permissions[fp["field"]] = fp

profile_settings[unquoted_profile]["fieldPermissions"] = field_permissions

# Parsing tabVisibilities as {"tabName1": "visibility", "tabName2": "Visibility"}
if "tabVisibilities" in result:
tab_visibilities = {}
Expand Down Expand Up @@ -2533,13 +2557,13 @@ def export_profile_settings():
if sobject in profile_settings[profile]["objectPermissions"]:
object_permission = profile_settings[profile]["objectPermissions"][sobject]
for crud in cruds:
rows.append("√" if object_permission[crud] == "true" else "x")
rows.append("√" if object_permission[crud] == "true" else "")
else:
for crud in cruds:
rows.append("x")
rows.append("")
else:
for crud in cruds:
rows.append("x")
rows.append("")

all_rows.append(",".join(rows))

Expand Down Expand Up @@ -2595,12 +2619,59 @@ def export_profile_settings():
if profile_settings[profile]["userPermissions"][permission_name] == "true":
rows.append("√")
else:
rows.append("x")
rows.append("")
else:
rows.append("x")
rows.append("")

all_rows.append(",".join(rows))

Printer.get("log").write("Writing profile user permission to "+outputdir)
with open(outputdir+"/UserPermissions.csv", "wb") as fp:
fp.write("\n".join(all_rows).encode("utf-8"))

#########################################
# 4. Export Field Level Security
#########################################
# Define object CRUD
rus = [
"readable", "editable"
]

# Define the column that contains profile
Printer.get("log").write("Generating csv content for profile field level security")
profile_headers = ["Object", "Field"]
for profile in profiles:
profile_headers.append(profile)
for i in range(len(rus) - 1):
profile_headers.append("")

# Define the column
ru_headers = ["", ""]
for profile in profiles:
for ru in rus:
ru_headers.append(ru.capitalize())

all_rows = [",".join(profile_headers), ",".join(ru_headers)]
for sobject in sorted(sobject_fields.keys()):
for field in sobject_fields[sobject]:
rows = [sobject, field]
object_field = "%s.%s" % (sobject, field)
for profile in profiles:
if object_field in profile_settings[profile]["fieldPermissions"]:
field_permission = profile_settings[profile]["fieldPermissions"][object_field]
for ru in rus:
rows.append("√" if field_permission[ru] == "true" else "")
else:
for ru in rus:
rows.append("")

# Every field is separated line
all_rows.append(",".join(rows))

outputdir = settings["workspace"]+ "/.export/profile"
if not os.path.exists(outputdir):
os.makedirs(outputdir)

Printer.get("log").write("Writing profile object security to "+outputdir)
with open(outputdir+"/FieldLevelSecurity.csv", "wb") as fp:
fp.write("\n".join(all_rows).encode("utf-8"))

0 comments on commit f9ddd5f

Please sign in to comment.