def __init__(self, *args): super(MembersBaseController,self).__init__(*args) self.community = find_interface(self.context, ICommunity) self.actions = _get_manage_actions(self.community, self.request) self.profiles = find_profiles(self.context) self.system_name = get_setting( self.context, 'system_name', 'OpenCore' ) self.data['actions']=self.actions
def __init__(self, context, request): self.context = context self.request = request self.community = find_interface(context, ICommunity) self.profiles = find_profiles(self.community) self.api = request.api self.actions = _get_manage_actions(self.community, request) self.desc = ('Use the form below to remove members or to resend invites ' 'to people who have not accepted your invitation to join ' 'this community.') self.defaults = self.form_defaults()
def show_members_view(context, request): """Default view of community members (with/without pictures).""" page_title = 'Community Members' api = request.api api.page_title = page_title # Filter the actions based on permission in the **community** community = find_interface(context, ICommunity) actions = _get_manage_actions(community, request) # Did we get the "show pictures" flag? hp = request.params.has_key('hide_pictures') mu = model_url(context, request) submenu = [ {'label': 'Show Pictures', 'href': mu, 'make_link': hp}, {'label': 'Hide Pictures', 'href': mu + '?hide_pictures', 'make_link': not(hp)}, ] profiles = find_profiles(context) member_batch = _member_profile_batch(context, request) member_entries = member_batch['entries'] moderator_names = community.moderator_names member_info = [] for i in range(len(member_entries)): derived = {} entry = member_entries[i] derived['title'] = entry.title derived['href'] = model_url(entry, request) derived['position'] = entry.position derived['organization'] = entry.organization derived['phone'] = entry.phone derived['department'] = entry.department derived['email'] = entry.email derived['city'] = entry.location photo = entry.get('photo') if photo is not None: derived['photo_url'] = thumb_url(photo, request, PROFILE_THUMB_SIZE) else: derived['photo_url'] = api.static_url + "/img/default_user.png" derived['is_moderator'] = entry.__name__ in moderator_names # Chameleon's tal:repeat and repeat variable support for # things like index is pretty iffy. Fix the entry info to # supply the CSS class information. derived['css_class'] = 'photoProfile' if derived['is_moderator']: derived['css_class'] += ' moderator' member_info.append(derived) moderator_info = [] profiles = find_profiles(context) for moderator_name in moderator_names: if moderator_name in profiles: derived = {} profile = profiles[moderator_name] if not has_permission('view', profile, request): continue derived['title'] = profile.title derived['href'] = model_url(profile, request) moderator_info.append(derived) return render_template_to_response( 'templates/show_members.pt', api=api, actions=actions, submenu=submenu, moderators=moderator_info, members=member_info, batch_info=member_batch, hide_pictures=hp, )