def authz_fieldset_builder(role_class): fs = fa.Grid(role_class) role_options = model.Role.get_all() if role_class == model.PackageRole: fs.append( Field(u'delete', types.String, get_package_linker(u'delete')).readonly() ) elif role_class == model.GroupRole: fs.append( Field(u'delete', types.String, get_group_linker(u'delete')).readonly() ) fs.append( # use getattr because though we should always have a user name, # sometimes (due to error) we don't and want to avoid a 500 ... Field(u'username', types.String, lambda item: ckan_h.linked_user(getattr(item.user, 'name', ''))).readonly() ) fs.configure( options = [ fs.role.with_renderer(RolesRenderer), ], include=[fs.username, fs.role, fs.delete], ) return fs
def authz_fieldset_builder(role_class): fs = fa.Grid(role_class) role_options = model.Role.get_all() if role_class == model.PackageRole: fs.append( Field(u'delete', types.String, get_package_linker(u'delete')).readonly()) elif role_class == model.GroupRole: fs.append( Field(u'delete', types.String, get_group_linker(u'delete')).readonly()) elif role_class == model.AuthorizationGroupRole: fs.append( Field(u'delete', types.String, get_authorization_group_linker(u'delete')).readonly()) fs.append( # use getattr because though we should always have a user name, # sometimes (due to error) we don't and want to avoid a 500 ... Field(u'username', types.String, lambda item: ckan_h.linked_user(getattr(item.user, 'name', '')) ).readonly()) fs.append( Field(u'authzgroupname', types.String, lambda item: getattr( item.authorized_group, 'name', '')).readonly()) fs.configure( options=[ fs.role.with_renderer(RolesRenderer), ], include=[fs.username, fs.authzgroupname, fs.role, fs.delete], ) return fs
def get_snippet_actor(activity, detail): user = authz.auth_is_loggedin_user() if not user: if i18n.get_lang() == 'fr': return literal( '''<span class="actor">%s</span>''' % "L'équipe de données ouvertes de l'Ontario".decode('utf8')) else: return literal('''<span class="actor">Ontario's Open Data Team \ </span>''') else: return literal('''<span class="actor">%s</span>''' % (helpers.linked_user(activity['user_id'], 0, 30)))
def eaw_theme_patch_linked_user(user, maxlength=0, avatar=20): res = linked_user(user, maxlength=0, avatar=20) # Get the username in case <user> is the id username = tk.get_action('user_show')(data_dict={'id': user})['name'] eawuserpic = eaw_theme_geteawuser(username) try: eawuserpic = eawuserpic.get('pic_url', '') except AttributeError: logger.warn("Could not find Eawag user picture") eawuserpic = '' else: res = re.sub('src="[^"]*?"', 'src={}'.format(eawuserpic), res, flags=re.S) return res
def get_snippet_user(activity, detail): return literal('''<span>%s</span>''' % (h.linked_user(activity['object_id'], 0, 20)) )
def get_snippet_actor(activity, detail): return literal('''<span class="actor">%s</span>''' % (h.linked_user(activity['user_id'], 0, 30)) )
def hdx_linked_user(user, maxlength=0): response = h.linked_user(user, maxlength) changed_response = re.sub(r"<img[^>]+/>", "", response) return h.literal(changed_response)
def get_snippet_user(activity, detail): return literal( '''<span data-module="popover-context" data-module-type="user" data-module-id="%s">%s</span>''' % (activity['object_id'], h.linked_user(activity['object_id'], 0, 20)))
def get_snippet_actor(activity, detail): return literal('''<span class="actor" data-module="popover-context" data-module-type="user" data-module-id="%s">%s</span>''' % (activity['user_id'], h.linked_user(activity['user_id'], 0, 30)) )
def get_snippet_user(activity, detail): return h.linked_user(activity['data']['user']['name'])
def get_snippet_actor(activity, detail): return h.linked_user(activity['user_id'])
def get_snippet_actor(activity, detail): return literal('''<span class="actor">%s</span>''' % (h.linked_user(activity['user_id'], 0, 30)))
def get_snippet_actor(activity, detail): return literal("""<span class="actor">%s</span>""" % (h.linked_user(activity["user_id"], 0, 30)))
def get_snippet_user(activity, detail): return literal('''<span>%s</span>''' % (h.linked_user(activity['object_id'], 0, 20)))
def get_snippet_user(activity, detail): return literal("""<span>%s</span>""" % (h.linked_user(activity["object_id"], 0, 20)))
def get_snippet_user(activity, detail): return literal('''<span data-module="popover-context" data-module-type="user" data-module-id="%s">%s</span>''' % (activity['object_id'], h.linked_user(activity['object_id'], 0, 20)) )
def get_snippet_actor(activity, detail): return literal( '''<span class="actor" data-module="popover-context" data-module-type="user" data-module-id="%s">%s</span>''' % (activity['user_id'], h.linked_user(activity['user_id'], 0, 30)))