예제 #1
0
파일: resource.py 프로젝트: zagy/karl
def delete_resource_view(context, request, num_children=0):

    page_title = 'Delete ' + context.title
    api = TemplateAPI(context, request, page_title)

    confirm = request.params.get('confirm')
    if confirm:
        location = resource_url(context.__parent__,
                                request,
                                query=dict(status_message='Deleted %s' %
                                           context.title))
        del context.__parent__[context.__name__]
        return HTTPFound(location=location)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout_name = 'generic'
    if find_intranet(context):
        layout_name = 'intranet'
    elif find_community(context):
        layout_name = 'community'
    layout = layout_provider(layout_name)

    return {
        'api': api,  # deprecated UX2
        'old_layout': layout,  # deprecated UX2
        'num_children': num_children,
    }
예제 #2
0
파일: resource.py 프로젝트: cguardia/karl
def delete_resource_view(context, request, num_children=0):

    page_title = 'Delete ' + context.title
    api = TemplateAPI(context, request, page_title)

    confirm = request.params.get('confirm')
    if confirm:
        location = model_url(
            context.__parent__, request,
            query=dict(status_message= 'Deleted %s' % context.title)
            )
        del context.__parent__[context.__name__]
        return HTTPFound(location=location)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    layout_name = 'generic'
    if find_intranet(context):
        layout_name = 'intranet'
    elif find_community(context):
        layout_name = 'community'
    layout = layout_provider(layout_name)

    return {'api': api,
            'layout': layout,
            'num_children': num_children,
           }
예제 #3
0
파일: advanced.py 프로젝트: zagy/karl
    def __call__(self):
        api = TemplateAPI(self.context, self.request, self.page_title)
        layout_provider = get_layout_provider(self.context, self.request)
        layout = layout_provider('community')
        intranet = find_intranet(self.context)
        if intranet is not None:
            ux2_layout = self.request.layout_manager.layout
            ux2_layout.section_style = "none"

        return {'api': api, 'actions': (), 'old_layout': layout}
예제 #4
0
파일: advanced.py 프로젝트: hj91/karl
    def __call__(self):
        api = TemplateAPI(self.context, self.request, self.page_title)
        layout_provider = get_layout_provider(self.context, self.request)
        layout = layout_provider('community')
        intranet = find_intranet(self.context)
        if intranet is not None:
            ux2_layout = self.request.layout_manager.layout
            ux2_layout.section_style = "none"

        return {'api':api, 'actions':(), 'old_layout':layout}
예제 #5
0
파일: layout.py 프로젝트: hj91/karl
    def __init__(self, context, request):
        self.context = context
        self.request = request
        self.app_url = request.application_url
        # what if context is not traversable?
        if getattr(context, '__name__', None) is not None:
            self.context_url = request.resource_url(context)
        else:
            self.context_url = request.url
        self.portlets = []
        self.settings = settings = request.registry.settings
        self.app_url = app_url = request.application_url
        if getattr(context, '__name__', '_no_name_') != '_no_name_':
            self.here_url = resource_url(context, request)
            self.site = find_site(context)
            chatter = find_chatter(context)
            self.chatter_url = resource_url(chatter, request)
        self.current_intranet = find_intranet(context)
        self.people_url = app_url + '/' + settings.get('people_path', 'people')
        self.profiles_url = app_url + '/profiles'
        self.project_name = settings.get('system_name', 'KARL')
        self.page_title = getattr(context, 'title', 'Page Title')
        self.userid = authenticated_userid(request)
        self.tinymce_height = 400
        self.tinymce_width = 560
        self.html_id_next = 0
        self.client_components = set()
        self.js_devel_mode = asbool(settings.get('js_devel_mode', 'false'))

        if self.settings:
            self.kaltura_info = dict(
                enabled =  self.settings.get(
                    'kaltura_enabled', False) in ('true', 'True'),
                partner_id = self.settings.get('kaltura_partner_id', ''),
                sub_partner_id = self.settings.get(
                    'kaltura_sub_partner_id', ''),
                admin_secret = self.settings.get('kaltura_admin_secret', ''),
                user_secret = self.settings.get('kaltura_user_secret', ''),
                kcw_uiconf_id = self.settings.get(
                    'kaltura_kcw_uiconf_id', '1000741'),
                player_uiconf_id = self.settings.get(
                    'kaltura_player_uiconf_id', ''),
                player_cache_st = self.settings.get(
                    'kaltura_player_cache_st', ''),
                local_user = self.userid,
            )
            if not self.settings.get(
                'kaltura_client_session', False) in ('true', 'True'):
                # Secrets will not be sent to client, instead session is handled on the server.
                self.kaltura_info['session_url'] = app_url + '/' + 'kaltura_create_session.json'
        else:
            self.kaltura_info = dict(
                enabled = False,
                )
예제 #6
0
파일: layout.py 프로젝트: hj91/karl
    def __init__(self, context, request):
        self.context = context
        self.request = request
        self.app_url = request.application_url
        # what if context is not traversable?
        if getattr(context, '__name__', None) is not None:
            self.context_url = request.resource_url(context)
        else:
            self.context_url = request.url
        self.portlets = []
        self.settings = settings = request.registry.settings
        self.app_url = app_url = request.application_url
        if getattr(context, '__name__', '_no_name_') != '_no_name_':
            self.here_url = resource_url(context, request)
            self.site = find_site(context)
            chatter = find_chatter(context)
            self.chatter_url = resource_url(chatter, request)
        self.current_intranet = find_intranet(context)
        self.people_url = app_url + '/' + settings.get('people_path', 'people')
        self.profiles_url = app_url + '/profiles'
        self.project_name = settings.get('system_name', 'KARL')
        self.page_title = getattr(context, 'title', 'Page Title')
        self.userid = authenticated_userid(request)
        self.tinymce_height = 400
        self.tinymce_width = 560
        self.html_id_next = 0
        self.client_components = set()
        self.js_devel_mode = asbool(settings.get('js_devel_mode', 'false'))

        if self.settings:
            self.kaltura_info = dict(
                enabled=self.settings.get('kaltura_enabled', False)
                in ('true', 'True'),
                partner_id=self.settings.get('kaltura_partner_id', ''),
                sub_partner_id=self.settings.get('kaltura_sub_partner_id', ''),
                admin_secret=self.settings.get('kaltura_admin_secret', ''),
                user_secret=self.settings.get('kaltura_user_secret', ''),
                kcw_uiconf_id=self.settings.get('kaltura_kcw_uiconf_id',
                                                '1000741'),
                player_uiconf_id=self.settings.get('kaltura_player_uiconf_id',
                                                   ''),
                player_cache_st=self.settings.get('kaltura_player_cache_st',
                                                  ''),
                local_user=self.userid,
            )
            if not self.settings.get('kaltura_client_session',
                                     False) in ('true', 'True'):
                # Secrets will not be sent to client, instead session is handled on the server.
                self.kaltura_info[
                    'session_url'] = app_url + '/' + 'kaltura_create_session.json'
        else:
            self.kaltura_info = dict(enabled=False, )
예제 #7
0
파일: references.py 프로젝트: zagy/karl
def reference_viewall_view(context, request):

    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
        }

    actions = []
    if has_permission('create', context, request):
        addables = get_folder_addables(context, request)
        if addables is not None:
            actions.extend(addables())
    if has_permission('edit', context, request):
        actions.append(('Edit', 'edit.html'))
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    old_layout = layout_provider('intranet')

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(
        tagbox = get_tags_client_data(context, request),
        )

    previous, next = get_previous_next(context, request, 'view_all.html')

    intranet = find_intranet(context)
    if intranet is not None:
        ux2_layout = request.layout_manager.layout
        ux2_layout.section_style = "none"

    return render_to_response(
        'templates/viewall_referencemanual.pt',
        dict(api=api,
             actions=actions,
             head_data=convert_to_script(client_json_data),
             tree=getTree(context, request, api),
             backto=backto,
             old_layout=old_layout,
             previous_entry=previous,
             next_entry=next),
        request=request,
        )
예제 #8
0
파일: references.py 프로젝트: zagy/karl
    def __call__(self):
        context = self.context
        request = self.request
        page_title = 'Edit %s' % context.title
        api = TemplateAPI(context, request, page_title)

        layout_provider = get_layout_provider(context, request)
        layout = layout_provider('intranet')
        intranet = find_intranet(self.context)
        if intranet is not None:
            ux2_layout = self.request.layout_manager.layout
            ux2_layout.section_style = "none"
        return {
            'api': api,             # deprecated UX1
            'old_layout': layout,   # deprecated UX1
            'actions': []}          # deprecated UX1
예제 #9
0
    def __call__(self):
        context = self.context
        request = self.request

        page_title = context.title
        api = TemplateAPI(context, request, page_title)
        karldates = getUtility(IKarlDates)

        actions = []
        if has_permission('create', context, request):
            actions = [(title, request.resource_url(context, view))
                       for title, view in self._admin_actions]

        forums = list(context.values())
        forums.sort(titlesort)

        forum_data = []

        for forum in forums:
            D = {}
            D['title'] = forum.title
            D['url'] = resource_url(forum, request)
            D['number_of_topics'] = number_of_topics(forum)
            D['number_of_comments'] = number_of_comments(forum, request)

            latest = latest_object(forum, request)

            _NOW = datetime.datetime.now()

            if latest:
                D['latest_activity_url'] = resource_url(latest, request)
                D['latest_activity_link'] = getattr(latest, 'title', None)
                D['latest_activity_by'] = getattr(latest, 'creator', None)
                modified = getattr(latest, 'modified_date', _NOW)
                modified_str = karldates(modified, 'longform')
                D['latest_activity_at'] = modified_str
            else:
                D['latest_activity_url'] = None
                D['latest_activity_link'] = None
                D['latest_activity_by'] = None
                D['latest_activity_at'] = None

            forum_data.append(D)

        client_json_data = dict(
            tagbox = get_tags_client_data(context, request),
            )

        layout = self.request.layout_manager.layout
        layout.section_style = "none"
        intranet = find_intranet(context)
        intranet_title = getattr(intranet, 'title', '')
        layout.page_title = '%s Forums' % intranet_title
        layout.head_data['panel_data']['tagbox'] = client_json_data['tagbox']
        layout.add_portlet('tagbox')
        return render_to_response(
            'templates/show_forums.pt',
            dict(api=api,
                 actions=actions,
                 forum_data = forum_data),
            request=request,
            )
예제 #10
0
class CustomFolderView(object):
    _past_events = None
    past_events_url = None
    future_events_url = None

    def __init__(self, context, request):
        self.context = context
        self.request = request

        searchterm = request.params.get('searchterm', None)
        if searchterm == '':
            searchterm = None
        self.searchterm = searchterm

        year = request.params.get('year', None)
        if year == 'all':
            year = None
        self.year = year

        month = request.params.get('month', None)
        if month == 'all':
            month = None
        self.month = month

    def __call__(self):
        """ Folder contents for the INetworkEvents marker"""
        context = self.context
        request = self.request

        page_title = context.title
        api = TemplateAPI(context, request, page_title)

        # Data for the filter bar, get the list of possible years and months
        this_year = datetime.datetime.now().year
        fb_years = [str(i) for i in range(2007, this_year+1)]
        fb_months = [('1', 'January'), ('2', 'February'), ('3', 'March'),
                     ('4', 'April'), ('5', 'May'), ('6', 'June'),
                     ('7', 'July'), ('8', 'August'), ('9', 'September'),
                     ('10', 'October'), ('11', 'November'), ('12', 'December')]

        # Flatten the search results into ZPT data
        try:
            batch = self._get_batch()
        except ParseError, e:
            api.set_error_message('Error: %s' % e)
            batch = {'entries': (), 'batching_required': False}

        entries = []
        for entry in batch["entries"]:
            info = {}
            info['url'] = resource_url(entry, request)
            info['title'] = entry.title
            info['date'] = self._get_date(entry)
            entries.append(info)

        # Actions and backlink
        actions = []
        if has_permission('create', context, request):
            addables = get_folder_addables(context, request)
            if addables is not None:
                actions.extend(addables())

        if has_permission('edit', context, request):
            actions.append(('Edit', 'edit.html'))

        if has_permission('delete', context.__parent__, request):
            actions.append(('Delete', 'delete.html'))

        if has_permission('administer', context, request):
            # admins see an Advanced action that puts markers on a folder.
            actions.append(('Advanced', 'advanced.html'))

        back_target, extra_path = get_user_home(context, request)
        backto = {
            'href': resource_url(back_target, request, *extra_path),
            'title': getattr(back_target, "title", "Home")
            }

        client_json_data = dict(
            tagbox = get_tags_client_data(context, request),
            )

        # Get a layout
        layout_provider = get_layout_provider(context, request)
        layout = layout_provider('community')

        intranet = find_intranet(self.context)
        intranets = find_intranets(self.context)
        community = find_community(self.context)
        if intranet is not None or community == intranets:
            ux2_layout = self.request.layout_manager.layout
            ux2_layout.section_style = "none"

        return dict(
            api=api,
            actions=actions,
            head_data=convert_to_script(client_json_data),
            backto=backto,
            old_layout=layout,
            entries=entries,
            fb_years=fb_years,
            fb_months=fb_months,
            searchterm=self.searchterm,
            selected_year=self.year,
            selected_month=self.month,
            batch_info=batch,
            past_events_url=self.past_events_url,
            future_events_url=self.future_events_url,
            )
예제 #11
0
파일: references.py 프로젝트: zagy/karl
def reference_outline_view(context, request):

    # Look for moveUp or moveDown in QUERY_STRING, telling us to
    # reorder something
    status_message = None
    subpath = request.params.get('subpath')

    backto = {
        'href': resource_url(context.__parent__, request),
        'title': context.__parent__.title,
        }

    user_can_edit = False
    actions = []
    if has_permission('create', context, request):
        addables = get_folder_addables(context, request)
        if addables is not None:
            actions.extend(addables())
    if has_permission('edit', context, request):
        user_can_edit = True
        actions.append(('Edit', 'edit.html'))
        if subpath:
            direction = request.params['direction']
            status_message = move_subpath(context, subpath, direction)
    if has_permission('delete', context, request):
        actions.append(('Delete', 'delete.html'))
    if has_permission('administer', context, request):
        actions.append(('Advanced', 'advanced.html'))

    page_title = context.title
    api = TemplateAPI(context, request, page_title)

    # Get a layout
    layout_provider = get_layout_provider(context, request)
    old_layout = layout_provider('intranet')

    # provide client data for rendering current tags in the tagbox
    client_json_data = dict(
        tagbox = get_tags_client_data(context, request),
        )

    previous, next = get_previous_next(context, request)

    intranet = find_intranet(context)
    if intranet is not None:
        ux2_layout = request.layout_manager.layout
        ux2_layout.section_style = "none"

    api.status_message = status_message
    return render_to_response(
        'templates/show_referencemanual.pt',
        dict(api=api,
             actions=actions,
             user_can_edit=user_can_edit,
             head_data=convert_to_script(client_json_data),
             tree=getTree(context, request, api),
             backto=backto,
             old_layout=old_layout,
             previous_entry=previous,
             next_entry=next),
        request=request,
        )
예제 #12
0
파일: api.py 프로젝트: boothead/karl
 def current_intranet(self):
     """The footer needs to know what intranet the curr url is in"""
     if self._current_intranet is None:
         self._current_intranet = find_intranet(self.context)
     return self._current_intranet
예제 #13
0
 def current_intranet(self):
     """The footer needs to know what intranet the curr url is in"""
     if self._current_intranet is None:
         self._current_intranet = find_intranet(self.context)
     return self._current_intranet