Skip to content

Commit

Permalink
export and reimport member portrait metadata and site admin role - re #…
Browse files Browse the repository at this point in the history
  • Loading branch information
ejucovy committed Mar 2, 2014
1 parent 8b0f7ed commit 3f69307
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
11 changes: 11 additions & 0 deletions opencore/browser/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ def __call__(self, *args, **kwargs):
if portrait:
portrait = open(os.path.join(portraits_dir, portrait), 'rb')
mem_obj.setPortrait(portrait)
portrait.filename = member['portrait_filename']
portrait.getField("creation_date").set(
portrait, DateTime(member['portrait_created_on']))
portrait.getField("modification_date").set(
portrait, DateTime(member['portrait_modified_on']))
portrait.Schema()['creators'].set(portrait, (member['portrait_creator'],))
portrait.creators = (member['portrait_creator'],)

if member['site_role'] == "admin":
context.manage_setLocalRoles(member['member_id'], ("Manager",))

mem_obj.reindexObject()

i += 1
Expand Down
25 changes: 22 additions & 3 deletions opencore/scripts/export_all_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def getMembersCSV(self, outfile, portrait_dir):
'favorites']

also = ['portrait',
'portrait_filename',
'portrait_created_on',
'portrait_modified_on',
'portrait_creator',

'site_role',
'is_confirmed',

Expand All @@ -78,7 +83,7 @@ def getMembersCSV(self, outfile, portrait_dir):
row.append(member.getLogin_time())
else:
row.append(member.getProperty(property))
portrait_url = ""
portrait_url = portrait_filename = portrait_created_on = portrait_modified_on = portrait_creator = ""
portrait = member.getPortrait()
if portrait:
extension = mimetypes.guess_extension(portrait.content_type) or ''
Expand All @@ -94,10 +99,24 @@ def getMembersCSV(self, outfile, portrait_dir):
assert isinstance(portrait.data.data, basestring)
portrait_file.write(portrait.data.data)
portrait_file.close()
portrait_filename = portrait.filename
portrait_created_on = str(portrait.created())
portrait_modified_on = str(portrait.modified())
portrait_creator = portrait.Creator()
row.append(portrait_url)
row.append(portrait_filename)
row.append(portrait_created_on)
row.append(portrait_modified_on)
row.append(portrait_creator)
print member.getId(), portrait_url
row.append("<SITE_ROLE>")
row.append(MemberWorkflowHandler(member).is_unconfirmed() and "unconfirmed" or "confirmed")

site_role = ""
if 'Manager' in app.openplans.get_local_roles_for_userid(memberId):
site_role = 'admin'
row.append(site_role)

row.append(MemberWorkflowHandler(member).is_unconfirmed() and "unconfirmed"
or "confirmed")
try:
memfolder = app.openplans.people[memberId]
except KeyError:
Expand Down

0 comments on commit 3f69307

Please sign in to comment.