def admin_channel_list(request): page = 'channel_list' title = 'Channels' page = util.paging_get_page(request) offset = util.paging_get_offset(page, ITEMS_BY_PAGE) filter = request.GET.get('filter', 'all') #owner = api.actor_lookup_nick(request.user, util.get_owner(request)) new_link = '/admin/channels/new' size, items = api.admin_get_channels(api.ROOT, ITEMS_BY_PAGE, offset, filter) start, end, next, prev, first, last = util.paging(page, ITEMS_BY_PAGE, size) base_url = '/admin/channels?' if filter is not None: filter_url = '&filter=%s' % filter group_menuitem = 'channel' menuitem = 'channel-list' channel_types = api.get_config_values(api.ROOT, 'channel_type') c = template.RequestContext(request, locals()) return render_to_response('administration/templates/channel_list.html', c)
def admin_channel_new(request): page = 'channel_new' title = 'Create a Channel' if request.method == 'POST': params = { 'nick': api.ROOT.nick, 'channel': request.POST.get('channel'), 'description': request.POST.get('description', ''), 'type':request.POST.get('type'), 'tags': request.POST.getlist('tags[]'), } channel_ref = api.channel_create(api.ROOT, **params) if channel_ref is not None: logging.info('Channel created %s' % channel_ref) return util.RedirectFlash('/admin/channels', "Channel created successfully") group_menuitem = 'channel' menuitem = 'channel-new' channel_types = api.get_config_values(api.ROOT, 'channel_type') c = template.RequestContext(request, locals()) return render_to_response('administration/templates/channel_new.html', c)
def join_join(request): if request.user: raise exception.AlreadyLoggedInException() redirect_to = request.REQUEST.get('redirect_to', '/') account_types = api.get_config_values(api.ROOT, 'account_type') # get the submitted vars nick = request.REQUEST.get('nick', ''); first_name = request.REQUEST.get('first_name', ''); last_name = request.REQUEST.get('last_name', ''); email = request.REQUEST.get('email', ''); password = request.REQUEST.get('password', ''); confirm = request.REQUEST.get('confirm', ''); hide = request.REQUEST.get('hide', ''); country_tag = request.REQUEST.get('country_tag', '') if request.POST: try: # TODO validate params = util.query_dict_to_keywords(request.POST) if hide: params['privacy'] = 2 # XXX: Check if the data come from a openid account # @author: [email protected] fromopenid = request.POST.get('fromopenid', False) and True if fromopenid: try: person = openidgae.get_current_person(request, http.HttpResponse()) except: raise exception.ServiceError email = person.get_email() if email == params['email']: params['password'] = util.generate_password() else: raise exception.ServiceError # ENDXXX validate.email(email) if not mail.is_allowed_to_send_email_to(email): raise exception.ValidationError("Cannot send email to that address") # TODO start transaction if api.actor_lookup_email(api.ROOT, email): raise exception.ValidationError( 'That email address is already associated with a member.') actor_ref = api.user_create(api.ROOT, **params) actor_ref.access_level = "delete" api.post(actor_ref, nick=actor_ref.nick, message='Joined %s!' % (util.get_metadata('SITE_NAME'))) if fromopenid: api.email_associate(api.ROOT, actor_ref.nick, email) else: # send off email confirmation api.activation_request_email(actor_ref, actor_ref.nick, email) logging.info('setting firsttime_%s from register page' % actor_ref.nick) memcache.client.set('firsttime_%s' % nick, True) # TODO end transaction welcome_url = util.qsa('/', {'redirect_to': redirect_to}) # NOTE: does not provide a flash message response = http.HttpResponseRedirect(welcome_url) user.set_user_cookie(response, actor_ref) return response except: exception.handle_exception(request) # for legal section legal_component = component.include('legal', 'dummy_legal') legal_html = legal_component.embed_join() # for sidebar sidebar_green_top = True area = "join" c = template.RequestContext(request, locals()) t = loader.get_template('join/templates/join.html') return http.HttpResponse(t.render(c))
def channel_settings(request, nick, page='index'): logging.info("channel_settings") nick = clean.channel(nick) view = api.actor_lookup_nick(request.user, nick) if not view: # Channel doesn't exist, bounce the user back so they can create it. # If the channel was just deleted, don't. This unfortunately, misses the # case where a user is attempting to delete a channel that doesn't # exist. return http.HttpResponseRedirect('/channel/%s' % nick) if page == 'details': logging.info("channel_settings_details: %s" % nick) channel_types = api.get_config_values(api.ROOT, 'channel_type') if request.method == "POST": tags = request.POST.getlist('tags[]') view.tags = tags view.put() handled = common_views.handle_view_action( request, { 'channel_update': request.path, 'actor_remove' : '/channel', } ) if page == 'photo' and not handled: handled = common_views.common_photo_upload(request, request.path, nick) if page == 'design' and not handled: handled = common_views.common_design_update(request, nick) if handled: return handled area = 'settings' avatars = display.DEFAULT_AVATARS actor_url = '/channel/%s' % nick if page == 'index': pass elif page == 'badge': badges = [{'id': 'badge-stream', 'width': '200', 'height': '300', 'src': '/themes/%s/badge.swf' % settings.DEFAULT_THEME, 'title': 'Stream', }, {'id': 'badge-map', 'width': '200', 'height': '255', 'src': '/themes/%s/badge-map.swf' % settings.DEFAULT_THEME, 'title': 'Map', }, {'id': 'badge-simple', 'width': '200', 'height': '200', 'src': '/themes/%s/badge-simple.swf' % settings.DEFAULT_THEME, 'title': 'Simple', }, ] elif page == 'delete': pass elif page == 'design': pass elif page == 'details': pass elif page == 'photo': pass elif page == 'tags': pass else: return common_views.common_404(request) # full_page adds the title of the sub-component. Not useful if it's the # main settings page if page != 'index': full_page = page.capitalize() # rendering c = template.RequestContext(request, locals()) t = loader.get_template('channel/templates/settings_%s.html' % page) return http.HttpResponse(t.render(c))