Esempio n. 1
0
def content_comments(context, content):
    # first level of comments
    content_type = ContentType.objects.get_for_model(content)
    is_moderated = (context['request'] and context['request'].user
                    and context['request'].user.is_staff)
    if is_moderated:
        comments = FreeThreadedComment.objects.all_for_object(
            content_object=content,
            parent__isnull=True).order_by('date_submitted')
    else:
        comments = FreeThreadedComment.public.all_for_object(
            content_object=content,
            parent__isnull=True).order_by('date_submitted')
    plugin_config = get_plugin('feedback').get_config()
    number_of_comments = plugin_config.get('number_of_comments').get_value()
    show_children = plugin_config.get('show_children').get_value()
    show_links = plugin_config.get('show_links').get_value()
    has_pagination = number_of_comments > 0
    print '>>>>>>>>>>', has_pagination, number_of_comments
    return {
        'content': content,
        'MEDIA_URL': context['MEDIA_URL'],
        'THEME_MEDIA_URL': context['THEME_MEDIA_URL'],
        'request': context['request'],
        'comments': comments,
        'content_type_id': content_type.id,
        'form': context.get('form', None),
        'number_of_comments': number_of_comments,
        'has_pagination': has_pagination,
        'show_children': show_children,
        'show_links': show_links,
    }
Esempio n. 2
0
def content_comments(context, content):
    # first level of comments
    content_type = ContentType.objects.get_for_model(content)
    is_moderated = (context['request'] and context['request'].user and context['request'].user.is_staff)
    if is_moderated:
        comments = FreeThreadedComment.objects.all_for_object(content_object=content, parent__isnull=True).order_by('date_submitted')
    else:
        comments = FreeThreadedComment.public.all_for_object(content_object=content, parent__isnull=True).order_by('date_submitted')
    plugin_config = get_plugin('feedback').get_config()
    number_of_comments = plugin_config.get('number_of_comments').get_value()
    show_children = plugin_config.get('show_children').get_value()
    show_links = plugin_config.get('show_links').get_value()
    has_pagination = number_of_comments > 0
    print '>>>>>>>>>>', has_pagination, number_of_comments
    return {'content': content,
            'MEDIA_URL': context['MEDIA_URL'],
            'THEME_MEDIA_URL': context['THEME_MEDIA_URL'],
            'request': context['request'],
            'comments': comments,
            'content_type_id': content_type.id,
            'form': context.get('form', None),
            'number_of_comments': number_of_comments,
            'has_pagination': has_pagination,
            'show_children': show_children,
            'show_links': show_links,
           }
    def handle(self, *args, **options):
        old_plugin = get_plugin('custommeta')
        old_plugin = old_plugin and old_plugin.get_registered_item()
        if not old_plugin or not old_plugin.installed:
            print "Old custommeta plugin is not installed. Nothing to do!"
            return
        if not old_plugin.active:
            print "Old custommeta plugin is installed but is not active. Nothing to do!"
            return
        from plugins.custommeta.models import CustomMeta as OldCustomMeta
        from plugins.core.models import CustomMeta

        old_objects = OldCustomMeta.objects.all()
        total = old_objects.count()

        print ('Importing %s old custommeta objects' % total)
        index = 1
        for i in old_objects:
            sys.stdout.write('CustomMeta object [%s/%s]\r' % (index, total))
            sys.stdout.flush()
            CustomMeta.objects.get_or_create(
                url_regexp=i.url_regexp,
                title=i.title,
                description=i.description,
                keywords=i.keywords)
            index += 1
        print '\nDone'
Esempio n. 4
0
def ranking_by_owner(request):
    piwik_url = get_plugin('piwik').get_config().get('url').get_value()
    return render_to_response('piwik/ranking_stats.html', {
        'by_owner': True,
        'piwik_url': piwik_url
    },
                              context_instance=RequestContext(request))
Esempio n. 5
0
 def post_actions(self):
     login_smal2_url = '/saml2/login/'
     plugin = RegisteredPlugin.objects.get_by_item(get_plugin('core'))
     login_url = plugin.config.get('login_url', None)
     if login_url != login_smal2_url and (not login_url or login_url == settings.LOGIN_URL):
         plugin.config['login_url'] = login_smal2_url
         plugin.save()
    def handle(self, *args, **options):
        old_plugin = get_plugin('custommeta')
        old_plugin = old_plugin and old_plugin.get_registered_item()
        if not old_plugin or not old_plugin.installed:
            print "Old custommeta plugin is not installed. Nothing to do!"
            return
        if not old_plugin.active:
            print "Old custommeta plugin is installed but is not active. Nothing to do!"
            return
        from plugins.custommeta.models import CustomMeta as OldCustomMeta
        from plugins.core.models import CustomMeta

        old_objects = OldCustomMeta.objects.all()
        total = old_objects.count()

        print('Importing %s old custommeta objects' % total)
        index = 1
        for i in old_objects:
            sys.stdout.write('CustomMeta object [%s/%s]\r' % (index, total))
            sys.stdout.flush()
            CustomMeta.objects.get_or_create(url_regexp=i.url_regexp,
                                             title=i.title,
                                             description=i.description,
                                             keywords=i.keywords)
            index += 1
        print '\nDone'
Esempio n. 7
0
def get_basecontents(data, extra_filters=None):
    pattern = ".*id:(\d+).*"
    contents = {}
    metric = get_plugin('piwik').get_config().get('metric').get_value() or METRIC
    for entry in data:
        match = re.match(pattern, entry['label'])
        id = None
        if match:
            id = match.groups()[0]
        if id:
            filters = {'id': id}
            if extra_filters:
                filters.update(extra_filters)
            try:
                content = BaseContent.objects.get(**filters)
            except BaseContent.DoesNotExist:
                continue

            if not content in contents:
                contents[content] = {}
            contents[content]['visits'] = contents[content].get('visits', 0) + entry.get(metric, 0)
            if 'subtable' in entry:
                children = get_basecontents(entry['subtable'])
                if contents[content].get('children', None):
                    for child, child_metric in children.iteritems():
                        if child in contents[content]['children']:
                            contents[content]['children'][child]['visits'] += child_metric['visits']
                        else:
                            contents[content]['children'].update({child: {'visits': child_metric['visits']}})
                else:
                    contents[content]['children'] = children

    return contents
Esempio n. 8
0
def get_login_url():
    from merengue.pluggable.utils import get_plugin
    core_config = get_plugin('core').get_config()
    login_url_conf = core_config.get('login_url', None)
    if not login_url_conf:
        return settings.LOGIN_URL
    else:
        return login_url_conf.get_value() or settings.LOGIN_URL
Esempio n. 9
0
def get_login_url():
    from merengue.pluggable.utils import get_plugin
    core_config = get_plugin('core').get_config()
    login_url_conf = core_config.get('login_url', None)
    if not login_url_conf:
        return settings.LOGIN_URL
    else:
        return login_url_conf.get_value() or settings.LOGIN_URL
Esempio n. 10
0
 def post_actions(self):
     login_smal2_url = '/saml2/login/'
     plugin = RegisteredPlugin.objects.get_by_item(get_plugin('core'))
     login_url = plugin.config.get('login_url', None)
     if login_url != login_smal2_url and (not login_url or login_url
                                          == settings.LOGIN_URL):
         plugin.config['login_url'] = login_smal2_url
         plugin.save()
Esempio n. 11
0
 def render(self, name, value, attrs=None):
     plugin = get_plugin('contactform')
     pubkey = plugin.get_config().get('rpubk', None)
     if pubkey:
         pubkey = pubkey.value
     else:
         pubkey = ''
     return captcha.displayhtml(pubkey)
Esempio n. 12
0
 def render(self, name, value, attrs=None):
     plugin = get_plugin('contactform')
     pubkey = plugin.get_config().get('rpubk', None)
     if pubkey:
         pubkey = pubkey.value
     else:
         pubkey = ''
     return captcha.displayhtml(pubkey)
Esempio n. 13
0
def get_profile_form():
    plugin_config = get_plugin('registration').get_config()
    form_class_string = plugin_config.get('profile_form_class').get_value()
    if not form_class_string:
        return None
    module_name, class_name = form_class_string.rsplit('.', 1)
    module = import_module(module_name)
    form_class = getattr(module, class_name)
    return form_class
Esempio n. 14
0
def index(request):
    """ Index page. You can override as you like """
    core_config = get_plugin('core').get_config()
    main_content_index = core_config['home_initial_content'].get_value()
    content = BaseContent.objects.get(pk=main_content_index).get_real_instance()
    return render_to_response([content._meta.content_view_template,
                               'website/index.html'],
                              {'content': content},
                              context_instance=RequestContext(request))
Esempio n. 15
0
 def actives(self):
     plugin_config = get_plugin('registration').get_config()
     caducity = plugin_config.get('caducity').get_value()
     qs = self.all()
     if caducity:
         now = datetime.datetime.now()
         from_date = now - datetime.timedelta(hours=caducity)
         return qs.filter(registration_date__gte=from_date)
     return qs
Esempio n. 16
0
 def render(self, request, place, context, *args, **kwargs):
     plugin = get_plugin("rss")
     portal_title = plugin.get_config().get('portal', '')
     feed_url = reverse('rss_views')
     return self.render_block(
         request, template_name='rss/global_block.html',
         block_title=_('RSS'),
         context={'feed_url': feed_url,
                  'portal_title': portal_title})
Esempio n. 17
0
def get_profile_form():
    plugin_config = get_plugin('registration').get_config()
    form_class_string = plugin_config.get('profile_form_class').get_value()
    if not form_class_string:
        return None
    module_name, class_name = form_class_string.rsplit('.', 1)
    module = import_module(module_name)
    form_class = getattr(module, class_name)
    return form_class
Esempio n. 18
0
 def actives(self):
     plugin_config = get_plugin('registration').get_config()
     caducity = plugin_config.get('caducity').get_value()
     qs = self.all()
     if caducity:
         now = datetime.datetime.now()
         from_date = now - datetime.timedelta(hours=caducity)
         return qs.filter(registration_date__gte=from_date)
     return qs
Esempio n. 19
0
def get_attribute_mapping():
    plugin_config = get_plugin('saml2').get_config()
    mapping = {
        'username': plugin_config['username_attribute'].get_value(),
        'first_name': plugin_config['first_name_attribute'].get_value(),
        'last_name': plugin_config['last_name_attribute'].get_value(),
        'email': plugin_config['email_attribute'].get_value(),
        }
    # reverse the mapping
    return dict([(str(v), (k,)) for k, v in mapping.items() if v])
Esempio n. 20
0
def index(request):
    """ Index page. You can override as you like """
    core_config = get_plugin('core').get_config()
    main_content_index = core_config['home_initial_content'].get_value()
    content = BaseContent.objects.get(
        pk=main_content_index).get_real_instance()
    return render_to_response(
        [content._meta.content_view_template, 'website/index.html'],
        {'content': content},
        context_instance=RequestContext(request))
Esempio n. 21
0
def create_redirect_review_task(user, obj):
    config = get_plugin('redirects').get_config()
    usernames = config.get('review_users', []).get_value() or []
    groupnames = config.get('review_groups', []).get_value() or []
    create_review_task(user,
        title=config['review_title'].get_value() or _('Review this redirection'),
        url=obj.old_path,
        task_object=obj,
        users=[u for u in User.objects.filter(username__in=usernames)],
        groups=[g for g in Group.objects.filter(name__in=groupnames)])
Esempio n. 22
0
def merengue_config_loader(request):
    site = Site.objects.get_current()
    site_url = 'http://' + site.domain + '/saml2/'
    entity_id = site_url + 'metadata/'
    plugin_config = get_plugin('saml2').get_config()
    config_dict = {
        # basic, mandatory stuff
        'xmlsec_binary': plugin_config['xmlsec_binary'].get_value(),
        'entityid': entity_id,
        'attribute_map_dir': os.path.join(BASEDIR, 'attribute-maps'),

        # this block states what services we provide
        'service': {
            'sp': {  # we are just a lonely SP
                'name': plugin_config['entity_name'].get_value(),
                'endpoints': {
                    'assertion_consumer_service': [
                        (site_url + 'acs/', saml2.BINDING_HTTP_POST),
                        ],
                    'single_logout_service': [
                        (site_url + 'ls/', saml2.BINDING_HTTP_REDIRECT),
                        ],
                    },
                'idp': get_idps(),
                },
            },

        'metadata': {
            'local': get_metadata_files(),
            },

        'debug': 1,

        # certificates
        'key_file': plugin_config['key_file_path'].get_value(),
        'cert_file': plugin_config['cert_file_path'].get_value(),

        # These fields are only used when generating the metadata
        'contact_person': get_contact_people(),
        'organization': get_organization(),
        'valid_for': plugin_config['valid_for'].get_value(),  # hours
        }

    required_attrs = split_str(plugin_config['required_attributes'].get_value())
    if required_attrs:
        config_dict['service']['sp']['required_attributes'] = required_attrs

    optional_attrs = split_str(plugin_config['optional_attributes'].get_value())
    if optional_attrs:
        config_dict['service']['sp']['optional_attributes'] = optional_attrs

    sp_config = saml2.config.SPConfig()
    sp_config.load(config_dict)
    return sp_config
Esempio n. 23
0
def generate_feed_from_queryset(request, queryset=None):
    plugin = get_plugin('rss')

    if not queryset:
        contenttypes = plugin.get_config().get(
            'contenttypes', []).get_value()
        query = Q()
        if not contenttypes or ALL_TYPES in contenttypes:
            queryset = BaseContent.objects.filter(
                status='published').order_by('-modification_date')
        else:
            classnames = [x for x in contenttypes]
            for classname in classnames:
                query = query | Q(class_name=classname.lower())
            queryset = BaseContent.objects.filter(
                            status='published').filter(
                            query).order_by('-modification_date')
        qsm = QueryStringManager(request)
        queryset = queryset.filter(**qsm.get_filters())

    portal_title = plugin.get_config().get(
        'portal', '').get_value()
    f = feedgenerator.Rss201rev2Feed(
        title=portal_title,
        link=render_to_string('rss/link.html'),
        description=render_to_string('rss/description.html'),
        language=render_to_string('rss/language.html'),
        author_name=render_to_string('rss/author_name.html'),
        feed_url=render_to_string('rss/feed_url.html'),
    )
    limit = plugin.get_config().get('limit', None)
    queryset = queryset[:int(limit.get_value())]
    link_prefix = 'http://%s' % Site.objects.all()[0].domain
    for item in queryset:
        if hasattr(item, 'get_real_instance'):
            item = item.get_real_instance()
        if 'modification_date' in item.__dict__:
            item_date = item.modification_date
        else:
            item_date = datetime.now()
        templates = {'title': ['rss/%s/title.html' % item.class_name,
                               'rss/items/title.html'],
                     'description': ['rss/%s/description.html' % item.class_name,
                               'rss/items/description.html'],
                    }
        f.add_item(
            title=render_to_string(templates['title'], {'item': item}),
            link=u'%s%s' % (link_prefix, item.public_link()),
            pubdate=item_date,
            description=render_to_string(templates['description'],
                                         {'item': item}),
        )

    return f.writeString('UTF-8')
Esempio n. 24
0
def generate_feed_from_queryset(request, queryset=None):
    plugin = get_plugin('rss')

    if not queryset:
        contenttypes = plugin.get_config().get('contenttypes', []).get_value()
        query = Q()
        if not contenttypes or ALL_TYPES in contenttypes:
            queryset = BaseContent.objects.filter(
                status='published').order_by('-modification_date')
        else:
            classnames = [x for x in contenttypes]
            for classname in classnames:
                query = query | Q(class_name=classname.lower())
            queryset = BaseContent.objects.filter(status='published').filter(
                query).order_by('-modification_date')
        qsm = QueryStringManager(request)
        queryset = queryset.filter(**qsm.get_filters())

    portal_title = plugin.get_config().get('portal', '').get_value()
    f = feedgenerator.Rss201rev2Feed(
        title=portal_title,
        link=render_to_string('rss/link.html'),
        description=render_to_string('rss/description.html'),
        language=render_to_string('rss/language.html'),
        author_name=render_to_string('rss/author_name.html'),
        feed_url=render_to_string('rss/feed_url.html'),
    )
    limit = plugin.get_config().get('limit', None)
    queryset = queryset[:int(limit.get_value())]
    link_prefix = 'http://%s' % Site.objects.all()[0].domain
    for item in queryset:
        if hasattr(item, 'get_real_instance'):
            item = item.get_real_instance()
        if 'modification_date' in item.__dict__:
            item_date = item.modification_date
        else:
            item_date = datetime.now()
        templates = {
            'title':
            ['rss/%s/title.html' % item.class_name, 'rss/items/title.html'],
            'description': [
                'rss/%s/description.html' % item.class_name,
                'rss/items/description.html'
            ],
        }
        f.add_item(
            title=render_to_string(templates['title'], {'item': item}),
            link=u'%s%s' % (link_prefix, item.public_link()),
            pubdate=item_date,
            description=render_to_string(templates['description'],
                                         {'item': item}),
        )

    return f.writeString('UTF-8')
Esempio n. 25
0
 def _build_context(self):
     site = Site.objects.get_current()
     # We use import get_plugin here to avoid circular dependencies
     from merengue.pluggable.utils import get_plugin
     plugin_config = get_plugin('ezdashboard').get_config()
     return {
         'gadget': self,
         'SITE_DOMAIN': site.domain,
         'SITE_URL': self._site_url(),
         'EZWEB_URL': plugin_config['url'].value,
     }
Esempio n. 26
0
 def render(self, request, place, context, *args, **kwargs):
     plugin = get_plugin("rss")
     portal_title = plugin.get_config().get('portal', '')
     feed_url = reverse('rss_views')
     return self.render_block(request,
                              template_name='rss/global_block.html',
                              block_title=_('RSS'),
                              context={
                                  'feed_url': feed_url,
                                  'portal_title': portal_title
                              })
Esempio n. 27
0
 def _build_context(self):
     site = Site.objects.get_current()
     # We use import get_plugin here to avoid circular dependencies
     from merengue.pluggable.utils import get_plugin
     plugin_config = get_plugin('ezdashboard').get_config()
     return {
         'gadget': self,
         'SITE_DOMAIN': site.domain,
         'SITE_URL': self._site_url(),
         'EZWEB_URL': plugin_config['url'].value,
     }
Esempio n. 28
0
 def clean(self, value):
     plugin = get_plugin('contactform')
     privkey = plugin.get_config().get('rprivk', None)
     if privkey:
         privkey = privkey.value
     else:
         privkey = ''
     challenge, response = value
     recaptcha_response = captcha.submit(challenge, response,
                                         privkey, self.client_addr)
     if not recaptcha_response.is_valid:
         raise ValidationError(_("The captcha was invalid, try again."))
Esempio n. 29
0
def create_redirect_review_task(user, obj):
    config = get_plugin('redirects').get_config()
    usernames = config.get('review_users', []).get_value() or []
    groupnames = config.get('review_groups', []).get_value() or []
    create_review_task(
        user,
        title=config['review_title'].get_value()
        or _('Review this redirection'),
        url=obj.old_path,
        task_object=obj,
        users=[u for u in User.objects.filter(username__in=usernames)],
        groups=[g for g in Group.objects.filter(name__in=groupnames)])
Esempio n. 30
0
 def clean(self, value):
     plugin = get_plugin('contactform')
     privkey = plugin.get_config().get('rprivk', None)
     if privkey:
         privkey = privkey.value
     else:
         privkey = ''
     challenge, response = value
     recaptcha_response = captcha.submit(challenge, response, privkey,
                                         self.client_addr)
     if not recaptcha_response.is_valid:
         raise ValidationError(_("The captcha was invalid, try again."))
Esempio n. 31
0
def create_itag_from_tag(sender, instance, **kwargs):

    try:
        instance.itag
    except ITag.DoesNotExist:
        itag = ITag(tag_ptr=instance)
        lang = get_plugin('itags').get_config().get('main_language', None)
        lang = lang and lang.value or None
        if lang in dict(settings.LANGUAGES).keys():
            setattr(itag, get_real_fieldname('tag_name', lang), instance.name)
        else:
            setattr(itag, get_fallback_fieldname('tag_name'), instance.name)
        itag.save_base(raw=True)
Esempio n. 32
0
def piwik_script(context):
    plugin_config = get_plugin('piwik').get_config()
    url = plugin_config.get('url').get_value()
    token = plugin_config.get('token').get_value()
    site_id = plugin_config.get('site_id').get_value()
    return {
        'url': url,
        'token': token,
        'site_id': site_id,
        'section': context.get('section'),
        'content': context.get('content'),
        'request': context.get('request')
    }
Esempio n. 33
0
def piwik_script(context):
    plugin_config = get_plugin("piwik").get_config()
    url = plugin_config.get("url").get_value()
    token = plugin_config.get("token").get_value()
    site_id = plugin_config.get("site_id").get_value()
    return {
        "url": url,
        "token": token,
        "site_id": site_id,
        "section": context.get("section"),
        "content": context.get("content"),
        "request": context.get("request"),
    }
Esempio n. 34
0
def create_itag_from_tag(sender, instance, **kwargs):

    try:
        instance.itag
    except ITag.DoesNotExist:
        itag = ITag(tag_ptr=instance)
        lang = get_plugin('itags').get_config().get('main_language', None)
        lang = lang and lang.value or None
        if lang in dict(settings.LANGUAGES).keys():
            setattr(itag, get_real_fieldname('tag_name', lang), instance.name)
        else:
            setattr(itag, get_fallback_fieldname('tag_name'), instance.name)
        itag.save_base(raw=True)
Esempio n. 35
0
def piwik_script(context):
    plugin_config = get_plugin('piwik').get_config()
    url = plugin_config.get('url').get_value()
    token = plugin_config.get('token').get_value()
    site_id = plugin_config.get('site_id').get_value()
    return {'url': url,
            'token': token,
            'site_id': site_id,
            'section_piwik_variable': SECTION_PIWIK_VARIABLE,
            'content_piwik_variable': CONTENT_PIWIK_VARIABLE,
            'section': context.get('section'),
            'content': context.get('content'),
            'custom_variables': CUSTOM_VARIABLES,
            'request': context.get('request')}
Esempio n. 36
0
 def __init__(self, user, content, data=None, *args, **kwargs):
     super(HotLinkForm, self).__init__(data, *args, **kwargs)
     self.content = content
     self.only_menu = True
     if user.is_superuser:
         choices = BaseSection.objects.all()
     else:
         class_names = ['basesection']
         subclasses = BaseSection.get_subclasses()
         class_names += [subclass.__name__.lower() for subclass in subclasses]
         choices = user.contents_owned.filter(class_name__in=class_names)
     if choices.count() == 1:
         self.fields['section'] = forms.ModelChoiceField(initial=choices[0],
                                                          queryset=choices,
                                                          label='',
                                                          widget=forms.HiddenInput)
     else:
         self.fields['section'] = forms.ModelChoiceField(queryset=choices,
                                                          label=_('Section'),
                                                          required=True,
                                                          help_text=_('Choose a section where save the menu'))
     name_lang = transmeta.get_real_fieldname('name', settings.LANGUAGE_CODE)
     self.fields['slug'].required = False
     if not data:
         self.fields['slug'].label = ''
         self.fields['slug'].widget = forms.HiddenInput()
     self.fields[name_lang].label = _('Name')
     self.fields[name_lang].initial = getattr(content, name_lang, unicode(content))
     try:
         get_plugin('standingout')
         self.fields['where_link'] = forms.ChoiceField(label=_('How do you want link?'),
                                                       choices=(('m', _('menu'),),
                                                                ('s', _('standing out'),)))
         self.fields['visible_by_roles'].help_text = _('The roles that will see this menu. Only if you select the choice link like menu')
         self.only_menu = False
     except ImportError:
         pass
Esempio n. 37
0
 def render(self, request, place, context, *args, **kwargs):
     content_groups = ContentGroup.objects.filter(contents=context['content'])
     if content_groups:
         filtered_contents = []
         filtered_contents_len = 0
         for cont in content_groups:
             for child_cont in cont.contents.order_by('contentgroupcontent__order'):
                 item = (child_cont.name, child_cont.get_absolute_url())
                 if not item in filtered_contents:
                     filtered_contents_len += 1
                     filtered_contents.append(item)
         filtered_contents_len = len(filtered_contents)
         numchars_global = float(get_plugin('contentmenu').get_config().get('numchars', []).get_value())
         numchars = (numchars_global - filtered_contents_len * 3) / filtered_contents_len
         return self.render_block(
             request, template_name='contentmenu/contentlinks_block.html',
             block_title=_('Content group links'),
             context={'contents': filtered_contents,
                      'numchars': numchars})
     else:
         return ''
Esempio n. 38
0
def get_basecontents(data, extra_filters=None):
    pattern = ".*id:(\d+).*"
    contents = {}
    metric = get_plugin('piwik').get_config().get(
        'metric').get_value() or METRIC
    for entry in data:
        match = re.match(pattern, entry['label'])
        id = None
        if match:
            id = match.groups()[0]
        if id:
            filters = {'id': id}
            if extra_filters:
                filters.update(extra_filters)
            try:
                content = BaseContent.objects.get(**filters)
            except BaseContent.DoesNotExist:
                continue

            if not content in contents:
                contents[content] = {}
            contents[content]['visits'] = contents[content].get(
                'visits', 0) + entry.get(metric, 0)
            if 'subtable' in entry:
                children = get_basecontents(entry['subtable'])
                if contents[content].get('children', None):
                    for child, child_metric in children.iteritems():
                        if child in contents[content]['children']:
                            contents[content]['children'][child][
                                'visits'] += child_metric['visits']
                        else:
                            contents[content]['children'].update(
                                {child: {
                                    'visits': child_metric['visits']
                                }})
                else:
                    contents[content]['children'] = children

    return contents
Esempio n. 39
0
def index(request):
    piwik_url = get_plugin('piwik').get_config().get('url').get_value()
    return render_to_response('piwik/index.html',
                              {'piwik_url': piwik_url},
                              context_instance=RequestContext(request))
Esempio n. 40
0
def ranking_by_owner(request):
    piwik_url = get_plugin('piwik').get_config().get('url').get_value()
    return render_to_response('piwik/ranking_stats.html',
                              {'by_owner': True,
                               'piwik_url': piwik_url},
                              context_instance=RequestContext(request))
Esempio n. 41
0
 def __init__(self, url=None, token_auth=None):
     self.config = get_plugin('piwik').get_config()
     self.url = url or self.get_piwik_url()
     self.token_auth = token_auth or self.get_token()
     (scheme, netloc, path, query, fragment) = urlparse.urlsplit(self.url)
     self.host = netloc
Esempio n. 42
0
 def __init__(self, url=None, token_auth=None):
     self.config = get_plugin('piwik').get_config()
     self.url = url or self.get_piwik_url()
     self.token_auth = token_auth or self.get_token()
     (scheme, netloc, path, query, fragment) = urlparse.urlsplit(self.url)
     self.host = netloc
Esempio n. 43
0
def get_plugin_config():
    return get_plugin("piwik").get_config()
Esempio n. 44
0
def get_location():
    from merengue.pluggable.utils import get_plugin
    plugin_config = get_plugin('filebrowser').get_config()
    return os.path.join(settings.MEDIA_ROOT, plugin_config['filebrowser_docs_root'].get_value())
Esempio n. 45
0
def get_base_url():
    from merengue.pluggable.utils import get_plugin
    plugin_config = get_plugin('filebrowser').get_config()
    return os.path.join(settings.MEDIA_URL, plugin_config['filebrowser_docs_url'].get_value())
Esempio n. 46
0
def get_base_url():
    from merengue.pluggable.utils import get_plugin
    plugin_config = get_plugin('filebrowser').get_config()
    return os.path.join(settings.MEDIA_URL,
                        plugin_config['filebrowser_docs_url'].get_value())
Esempio n. 47
0
def get_location():
    from merengue.pluggable.utils import get_plugin
    plugin_config = get_plugin('filebrowser').get_config()
    return os.path.join(settings.MEDIA_ROOT,
                        plugin_config['filebrowser_docs_root'].get_value())
Esempio n. 48
0
def index(request):
    piwik_url = get_plugin('piwik').get_config().get('url').get_value()
    return render_to_response('piwik/index.html', {'piwik_url': piwik_url},
                              context_instance=RequestContext(request))
Esempio n. 49
0
def dashboard(request):
    plugin_config = get_plugin('ezdashboard').get_config()
    return render_to_response('ezdashboard/dashboard.html',
                              {'plugin_config': plugin_config},
                              context_instance=RequestContext(request))