コード例 #1
0
ファイル: __init__.py プロジェクト: hpoul/sct-communitytools
def setup_indices():
    from .models import Post
    global post_index

    try:
        post_index = Post.indexer
    except Exception as e:
        from djapian.indexer import Indexer

        searchboard_post_index = sphsettings.get_sph_setting('sphsearchboard_post_index', '/var/cache/sct/postindex/')

        if not os.path.isdir(searchboard_post_index):
            os.makedirs(searchboard_post_index)

        Post.index_model = 'sphene.sphsearchboard.models.post_index'
        post_index = Indexer(
            path=searchboard_post_index,

            model=Post,

            fields=[('subject', 20), 'body'],

            tags=[
                ('subject', 'subject', 20),
                ('date', 'postdate'),
                ('category', 'category.name'),
                ('post_id', 'id'),
                ('category_id', 'category.id'),
                ('group_id', 'category.group.id'),
            ])

        post_index.boolean_fields = ('category_id', 'group_id',)
コード例 #2
0
def setup_indices():
    from .models import Post
    global post_index

    try:
        post_index = Post.indexer
    except Exception as e:
        from djapian.indexer import Indexer

        searchboard_post_index = sphsettings.get_sph_setting(
            'sphsearchboard_post_index', '/var/cache/sct/postindex/')

        if not os.path.isdir(searchboard_post_index):
            os.makedirs(searchboard_post_index)

        Post.index_model = 'sphene.sphsearchboard.models.post_index'
        post_index = Indexer(path=searchboard_post_index,
                             model=Post,
                             fields=[('subject', 20), 'body'],
                             tags=[
                                 ('subject', 'subject', 20),
                                 ('date', 'postdate'),
                                 ('category', 'category.name'),
                                 ('post_id', 'id'),
                                 ('category_id', 'category.id'),
                                 ('group_id', 'category.group.id'),
                             ])

        post_index.boolean_fields = (
            'category_id',
            'group_id',
        )
コード例 #3
0
def get_public_emailaddress_help():
    # TODO also add a notice about wether anonymous user require to enter a captcha ?
    if get_sph_setting('community_email_show_only_public'):
        return _(
            'This email address will be shown to all users. If you leave it black noone will see your email address.')
    return _(
        'This email address will be shown to all users. If you leave it blank, your verified email address will be shown.')
コード例 #4
0
 def clean_username(self):
     case_sensitive_uname = sphsettings.get_sph_setting('community_register_username_casesensitive', True)
     if ((case_sensitive_uname and User.objects.filter(username__exact=self.cleaned_data['username']).exists())
         or
         (not case_sensitive_uname and User.objects.filter(username__iexact=self.cleaned_data['username']).exists())):
         raise forms.ValidationError(ugettext(u'The username %(username)s is already taken.') % {'username': self.cleaned_data['username']})
     return self.cleaned_data['username']
コード例 #5
0
class CommunityUserProfile(models.Model):
    user = models.ForeignKey( User, unique = True, verbose_name=ugettext_lazy(u'User'))
    displayname = models.CharField(ugettext_lazy(u'Display name'), max_length = 250)
    public_emailaddress = models.CharField(ugettext_lazy(u'Public email address'), max_length = 250)

    avatar = models.ImageField( ugettext_lazy(u'Avatar'),
                                height_field = 'avatar_height',
                                width_field = 'avatar_width',
                                upload_to = get_sph_setting('community_avatar_upload_to'),
                                blank = True, null = True, )
    avatar_height = models.IntegerField(ugettext_lazy(u'Avatar height'), blank = True, null = True, )
    avatar_width = models.IntegerField(ugettext_lazy(u'Avatar width'), blank = True, null = True, )


    changelog = ( ( '2007-08-10 00', 'alter', 'ADD avatar varchar(100)'   ),
                  ( '2007-08-10 01', 'alter', 'ADD avatar_height integer' ),
                  ( '2007-08-10 02', 'alter', 'ADD avatar_width integer'  ),
                  ( '2008-04-10 00', 'alter', 'ADD displayname varchar(250)' ),
                  ( '2008-04-10 01', 'update', "SET displayname = ''" ),
                  ( '2008-04-10 02', 'alter', 'ALTER displayname SET NOT NULL' ),
                )

    class Meta:
        verbose_name = ugettext_lazy('Community user profile')
        verbose_name_plural = ugettext_lazy('Community user profiles')
コード例 #6
0
 def process_view(self, request, view_func, view_args, view_kwargs):
     request.attributes = { }
     if 'urlPrefix' in view_kwargs:
         urlPrefix = view_kwargs['urlPrefix']
         if urlPrefix != '':
             urlPrefix = '/' + urlPrefix
         request.attributes['urlPrefix'] = urlPrefix
         del view_kwargs['urlPrefix']
     group = None
     groupName = None
     if get_current_urlconf_params() and 'groupName' in get_current_urlconf_params():
         groupName = get_current_urlconf_params()['groupName']
         # Check if we already loaded the current group in another
         # middleware.
         group = get_current_group()
         if group is None or group.name != groupName:
             group = get_object_or_404(Group, name = groupName)
     if 'groupName' in view_kwargs:
         if view_kwargs.get( 'noGroup', False ):
             del view_kwargs['groupName']
             del view_kwargs['noGroup']
         else:
             groupName = view_kwargs['groupName']
             if groupName == None: groupName = get_current_urlconf_params()['groupName']
             sphdata = get_current_sphdata()
             if group == None:
                 group = get_object_or_404(Group, name = groupName )
                 sphdata['group_fromhost'] = not get_sph_setting('community_groups_in_url')
             del view_kwargs['groupName']
             view_kwargs['group'] = group
             request.attributes['group'] = group
             #settings.TEMPLATE_DIRS = ( "/tmp/hehe", ) + settings.TEMPLATE_DIRS
             
     set_current_group( group )
     return None
コード例 #7
0
def include_css(csspath, prefix = None):
    styleincludes = sphsettings.get_sph_setting( 'community_styleincludes', [])

    if csspath in styleincludes:
        return

    if prefix is None:
        prefix = settings.MEDIA_URL
    styleincludes.append(prefix + csspath)
    sphsettings.set_sph_setting( 'community_styleincludes', styleincludes )
コード例 #8
0
ファイル: sphutils.py プロジェクト: sunilpatelmca/dishnine
def include_css(csspath, prefix=None):
    styleincludes = sphsettings.get_sph_setting('community_styleincludes', [])

    if csspath in styleincludes:
        return

    if prefix is None:
        prefix = settings.MEDIA_URL
    styleincludes.append(prefix + csspath)
    sphsettings.set_sph_setting('community_styleincludes', styleincludes)
コード例 #9
0
 def clean_username(self):
     case_sensitive_uname = sphsettings.get_sph_setting(
         'community_register_username_casesensitive', True)
     if ((case_sensitive_uname and User.objects.filter(
             username__exact=self.cleaned_data['username']).exists())
             or (not case_sensitive_uname and User.objects.filter(
                 username__iexact=self.cleaned_data['username']).exists())):
         raise forms.ValidationError(
             ugettext(u'The username %(username)s is already taken.') %
             {'username': self.cleaned_data['username']})
     return self.cleaned_data['username']
コード例 #10
0
ファイル: views.py プロジェクト: sunilpatelmca/dishnine
def groupaware_redirect_to(request, url, group, **kwargs):
    """
    Redirects either to the url given as 'url' or to a mapping defined in
    the SPH_SETTINGS variable 'community_groupaware_startpage'
    """
    group_name = group.name
    startpages = sphsettings.get_sph_setting('community_groupaware_startpage', None)
    if startpages is not None:
        if group_name in startpages:
            return HttpResponsePermanentRedirect(startpages[group_name] % kwargs)

    return HttpResponsePermanentRedirect(url % kwargs)
コード例 #11
0
    def get_contents(self, origin):
        group = get_current_group()
        template_name: str = origin.template_name
        if group is None:
            # If there is no current group .. we have nothing to do ..
            raise TemplateDoesNotExist(template_name)

        template_dir: str = sphsettings.get_sph_setting('community_groupaware_template_dir', None)

        if template_dir is not None:
            template_path = safe_join(os.path.join(template_dir, group.name), template_name)
            try:
                with open(template_path, encoding=self.engine.file_charset) as fp:
                    return fp.read()
            except FileNotFoundError as e:
                #logger.debug('File not found', e)
                pass

            prefix = 'groups/%s/' % group.name
            if template_name.startswith(prefix):
                template_name = template_name.replace(prefix, '')
                template_path = safe_join(os.path.join(template_dir, group.name), template_name)
                try:
                    with open(template_path, encoding=self.engine.file_charset) as fp:
                        return fp.read()
                except FileNotFoundError as e:
                    logger.warning('File no found', e)


        # Look in the cache . .so we don't have to make unnecessary database
        # queries
        cachekey = _get_cache_key(template_name, group)
        ret = cache.get( cachekey )
        if ret is not None:
            if ret == NOT_EXIST_CACHE_VALUE:
                raise TemplateDoesNotExist(template_name)

            return ret

        while group is not None:
            try:
                template = GroupTemplate.objects.get( template_name = template_name,
                                                      group = group, )
                ret = (template.source, "%s:%s" % (group.name, template.template_name))
                # Cache for two hours by default ..
                cache.set(cachekey, ret, TMPL_CACHE_EXPIRE)
                return ret
            except GroupTemplate.DoesNotExist:
                group = group.parent

        cache.set(cachekey, NOT_EXIST_CACHE_VALUE, TMPL_CACHE_EXPIRE)
        raise TemplateDoesNotExist(template_name)
コード例 #12
0
def groupaware_redirect_to(request, url, group, **kwargs):
    """
    Redirects either to the url given as 'url' or to a mapping defined in
    the SPH_SETTINGS variable 'community_groupaware_startpage'
    """
    group_name = group.name
    startpages = sphsettings.get_sph_setting('community_groupaware_startpage',
                                             None)
    if startpages is not None:
        if group_name in startpages:
            return HttpResponsePermanentRedirect(startpages[group_name] %
                                                 kwargs)

    return HttpResponsePermanentRedirect(url % kwargs)
コード例 #13
0
def load_template_source(template_name, template_dirs=None):
    """
    Template loader which loads templates from the database based on
    the current group.
    """
    group = get_current_group()
    if group is None:
        # If there is no current group .. we have nothing to do ..
        raise TemplateDoesNotExist(template_name)

    template_dir = sphsettings.get_sph_setting(
        'community_groupaware_template_dir', None)
    if template_dir is not None:
        try:
            template_path = safe_join(os.path.join(template_dir, group.name),
                                      template_name)
            return (open(template_path).read().decode(settings.FILE_CHARSET),
                    template_path)
        except:
            pass

    # Look in the cache . .so we don't have to make unnecessary database
    # queries
    cachekey = _get_cache_key(template_name, group)
    ret = cache.get(cachekey)
    if ret is not None:
        if ret == NOT_EXIST_CACHE_VALUE:
            raise TemplateDoesNotExist(template_name)

        return ret

    while group is not None:
        try:
            template = GroupTemplate.objects.get(
                template_name=template_name,
                group=group,
            )
            ret = (template.source,
                   "%s:%s" % (group.name, template.template_name))
            # Cache for two hours by default ..
            cache.set(cachekey, ret, TMPL_CACHE_EXPIRE)
            return ret
        except GroupTemplate.DoesNotExist:
            group = group.parent

    cache.set(cachekey, NOT_EXIST_CACHE_VALUE, TMPL_CACHE_EXPIRE)
    raise TemplateDoesNotExist(template_name)
コード例 #14
0
def load_template_source(template_name, template_dirs=None):
    """
    Template loader which loads templates from the database based on
    the current group.
    """
    try:
        group = get_current_group()
    except:
        # Ignore the error for now.
        # this can happen in combination with 'django app plugins' application
        # during syncdb see: http://sct.sphene.net/board/thread/1864/error-while-running-syncdb/?page=1#post-1864
        raise TemplateDoesNotExist(template_name)
    if group is None:
        # If there is no current group .. we have nothing to do ..
        raise TemplateDoesNotExist(template_name)

    template_dir = sphsettings.get_sph_setting('community_groupaware_template_dir', None)
    if template_dir is not None:
        try:
            template_path = safe_join(os.path.join(template_dir, group.name), template_name)
            return (open(template_path).read().decode(settings.FILE_CHARSET), template_path)
        except:
            pass

    # Look in the cache . .so we don't have to make unnecessary database
    # queries
    cachekey = _get_cache_key(template_name, group)
    ret = cache.get( cachekey )
    if ret is not None:
        if ret == NOT_EXIST_CACHE_VALUE:
            raise TemplateDoesNotExist(template_name)
        
        return ret

    while group is not None:
        try:
            template = GroupTemplate.objects.get( template_name = template_name,
                                                  group = group, )
            ret = (template.source, "%s:%s" % (group.name, template.template_name))
            # Cache for two hours by default ..
            cache.set(cachekey, ret, TMPL_CACHE_EXPIRE)
            return ret
        except GroupTemplate.DoesNotExist:
            group = group.parent

    cache.set(cachekey, NOT_EXIST_CACHE_VALUE, TMPL_CACHE_EXPIRE)
    raise TemplateDoesNotExist(template_name)
コード例 #15
0
class GroupMiddleware(object):
    def process_view(self, request, view_func, view_args, view_kwargs):
        request.attributes = {}
        if 'urlPrefix' in view_kwargs:
            urlPrefix = view_kwargs['urlPrefix']
            if urlPrefix != '':
                urlPrefix = '/' + urlPrefix
            request.attributes['urlPrefix'] = urlPrefix
            del view_kwargs['urlPrefix']
        group = None
        groupName = None
        if get_current_urlconf_params(
        ) and 'groupName' in get_current_urlconf_params():
            groupName = get_current_urlconf_params()['groupName']
            # Check if we already loaded the current group in another
            # middleware.
            group = get_current_group()
            if group is None or group.name != groupName:
                try:
                    group = get_object_or_404(Group, name=groupName)
                except Http404, e:
                    # We allow access to admin site without group.
                    if not view_func.__module__.startswith(
                            'django.contrib.admin.'):
                        raise e
        if 'groupName' in view_kwargs:
            if view_kwargs.get('noGroup', False):
                del view_kwargs['groupName']
                del view_kwargs['noGroup']
            else:
                groupName = view_kwargs['groupName']
                if groupName == None:
                    groupName = get_current_urlconf_params()['groupName']
                sphdata = get_current_sphdata()
                if group == None:
                    group = get_object_or_404(Group, name=groupName)
                    sphdata['group_fromhost'] = not get_sph_setting(
                        'community_groups_in_url')
                del view_kwargs['groupName']
                view_kwargs['group'] = group
                request.attributes['group'] = group
                #settings.TEMPLATE_DIRS = ( "/tmp/hehe", ) + settings.TEMPLATE_DIRS

        set_current_group(group)
        return None
コード例 #16
0
def website_thumbnail_url(url, width):
    width = str(width)
    type = 'jpg'
    cache_root = os.path.join('cache', 'sphlinklist', 'thumbnail')
    cache_key = '%s.%s' % (b64encode(':'.join([url, width]).encode('utf-8')).decode('utf-8'), type)
    cache_path = os.path.join(cache_root, cache_key)
    local_cache_file = os.path.join(settings.MEDIA_ROOT, cache_path)
    os.makedirs(os.path.join(settings.MEDIA_ROOT, cache_root), exist_ok=True)
    if not os.path.exists(local_cache_file):
        logger.debug('Downloading thumbnail for url %s into %s', url, local_cache_file)
        apikey = sphsettings.get_sph_setting('sphlinklist_thumbnail.ws_apikey')
        response = requests.get('https://api.thumbnail.ws/api/%s/thumbnail/get' % apikey,
                                params={'url': url, 'width': width}
                                )
        with open(local_cache_file, 'wb') as buf:
            buf.write(response.content)

    return { 'url': settings.MEDIA_URL + cache_path }
コード例 #17
0
def load_template_source(template_name, template_dirs=None):
    """
    Template loader which loads templates from the database based on
    the current group.
    """
    group = get_current_group()
    if group is None:
        # If there is no current group .. we have nothing to do ..
        raise TemplateDoesNotExist(template_name)

    template_dir = sphsettings.get_sph_setting('community_groupaware_template_dir', None)
    if template_dir is not None:
        try:
            template_path = safe_join(os.path.join(template_dir, group.name), template_name)
            return (open(template_path).read().decode(settings.FILE_CHARSET), template_path)
        except:
            pass

    # Look in the cache . .so we don't have to make unnecessary database
    # queries
    cachekey = _get_cache_key(template_name, group)
    ret = cache.get( cachekey )
    if ret is not None:
        if ret == NOT_EXIST_CACHE_VALUE:
            raise TemplateDoesNotExist(template_name)
        
        return ret

    while group is not None:
        try:
            template = GroupTemplate.objects.get( template_name = template_name,
                                                  group = group, )
            ret = (template.source, "%s:%s" % (group.name, template.template_name))
            # Cache for two hours by default ..
            cache.set(cachekey, ret, TMPL_CACHE_EXPIRE)
            return ret
        except GroupTemplate.DoesNotExist:
            group = group.parent

    cache.set(cachekey, NOT_EXIST_CACHE_VALUE, TMPL_CACHE_EXPIRE)
    raise TemplateDoesNotExist(template_name)
コード例 #18
0
    def handleMacroCall(self, doc, params):
        if 'id' in params:
            try:
                attachment = WikiAttachment.objects.get(id=params['id'])
            except WikiAttachment.DoesNotExist:
                return HTML('<b>Attachment for image does not exist: %s</b>' %
                            params['id'])
            el = doc.createElement('img')
            el.setAttribute('src', attachment.fileupload.url)

            cssclass = get_sph_setting('getwiki_macros_default_image_class')
            if cssclass is not None:
                el.setAttribute('class', cssclass)

            for paramName in ['class', 'width', 'height', 'alt', 'align']:
                if paramName in params:
                    el.setAttribute(paramName, params[paramName])

            if 'resize' in params:
                size = params['resize']
                width, height = size.split('x')
                src, width, height = resize(attachment.fileupload, size)
                el.setAttribute('src', src)
                el.setAttribute('width', '%dpx' % width)
                el.setAttribute('height', '%dpx' % height)

            # Create a link to view the image maximized.
            if not 'nolink' in params or not params['nolink']:
                el.setAttribute('border', '0')
                a = doc.createElement('a')
                a.setAttribute('href', attachment.fileupload.url)

                if cssclass is not None:
                    a.setAttribute('class', cssclass)

                a.appendChild(el)
                el = a

            return el
        return doc.createTextNode("Error, no 'id' given for img macro.")
コード例 #19
0
def community_profile_display(sender, signal, request, user, **kwargs):
    try:
        profile = CommunityUserProfile.objects.get(user=user, )
    except CommunityUserProfile.DoesNotExist:
        return None
    from sphene.sphboard.utils import is_spammer
    ret = ''
    fields = CommunityUserProfileField.objects.all()
    apply_spammer_limits = is_spammer(user.pk)
    for field in fields:
        if apply_spammer_limits and field.name in get_sph_setting('community_user_profile_spammer_restricted_fields'):
            continue
        try:
            value = CommunityUserProfileFieldValue.objects.get(user_profile=profile,
                                                               profile_field=field, )
            formatstring = '<tr><th>%(label)s</th><td>' + (field.renderstring or '%(value)s') + '</td></tr>'
            ret += (formatstring % {'label': field.name,
                                    'value': value.value, })
        except CommunityUserProfileFieldValue.DoesNotExist:
            continue

    return ret
コード例 #20
0
    def handleMacroCall(self, doc, params):
        if params.has_key( 'id' ):
            try:
                attachment = WikiAttachment.objects.get( id = params['id'] )
            except WikiAttachment.DoesNotExist:
                return HTML( '<b>Attachment for image does not exist: %s</b>' % params['id'] )
            el = doc.createElement( 'img' )
            el.setAttribute( 'src', attachment.fileupload.url )

            cssclass = get_sph_setting('getwiki_macros_default_image_class')
            if cssclass is not None:
                el.setAttribute('class', cssclass)

            for paramName in [ 'class', 'width', 'height', 'alt', 'align' ]:
                if params.has_key( paramName ):
                    el.setAttribute( paramName, params[paramName] )

            if params.has_key('resize'):
                size = params['resize']
                width, height = size.split('x')
                src, width, height = resize(attachment.fileupload, size)
                el.setAttribute('src', src)
                el.setAttribute('width', '%dpx' % width)
                el.setAttribute('height', '%dpx' % height)

            # Create a link to view the image maximized.
            if not 'nolink' in params or not params['nolink']:
                el.setAttribute( 'border', '0' )
                a = doc.createElement( 'a' )
                a.setAttribute( 'href', attachment.fileupload.url )

                if cssclass is not None:
                    a.setAttribute('class', cssclass)

                a.appendChild(el)
                el = a

            return el
        return doc.createTextNode("Error, no 'id' given for img macro.")
コード例 #21
0
ファイル: models.py プロジェクト: pigletto/sct-communitytools
def community_profile_display(sender, signal, request, user, **kwargs):
    try:
        profile = CommunityUserProfile.objects.get( user = user, )
    except CommunityUserProfile.DoesNotExist:
        return None
    from sphene.sphboard.utils import is_spammer
    ret = ''
    fields = CommunityUserProfileField.objects.all()
    apply_spammer_limits = is_spammer(user.pk)
    for field in fields:
        if apply_spammer_limits and field.name in get_sph_setting('community_user_profile_spammer_restricted_fields'):
            continue
        try:
            value = CommunityUserProfileFieldValue.objects.get( user_profile = profile,
                                                                profile_field = field, )
            formatstring = '<tr><th>%(label)s</th><td>' + (field.renderstring or '%(value)s') + '</td></tr>'
            ret += (formatstring % { 'label': field.name,
                                     'value': value.value, })
        except CommunityUserProfileFieldValue.DoesNotExist:
            continue

    return ret
コード例 #22
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        request.attributes = {}
        if "urlPrefix" in view_kwargs:
            urlPrefix = view_kwargs["urlPrefix"]
            if urlPrefix != "":
                urlPrefix = "/" + urlPrefix
            request.attributes["urlPrefix"] = urlPrefix
            del view_kwargs["urlPrefix"]
        group = None
        groupName = None
        if get_current_urlconf_params() and "groupName" in get_current_urlconf_params():
            groupName = get_current_urlconf_params()["groupName"]
            # Check if we already loaded the current group in another
            # middleware.
            group = get_current_group()
            if group is None or group.name != groupName:
                group = get_object_or_404(Group, name=groupName)
        if "groupName" in view_kwargs:
            if view_kwargs.get("noGroup", False):
                del view_kwargs["groupName"]
                del view_kwargs["noGroup"]
            else:
                groupName = view_kwargs["groupName"]
                if groupName == None:
                    groupName = get_current_urlconf_params()["groupName"]
                sphdata = get_current_sphdata()
                if group == None:
                    group = get_object_or_404(Group, name=groupName)
                    sphdata["group_fromhost"] = not get_sph_setting("community_groups_in_url")
                del view_kwargs["groupName"]
                view_kwargs["group"] = group
                request.attributes["group"] = group
                # settings.TEMPLATE_DIRS = ( "/tmp/hehe", ) + settings.TEMPLATE_DIRS

        set_current_group(group)
        return None
コード例 #23
0
ファイル: models.py プロジェクト: sunilpatelmca/dishnine
def get_user_displayname_help():
    if get_sph_setting( 'community_user_displayname_fallback' ) == 'username':
        return _('This display name will be shown to all users. If you leave it blank then your username will be shown.')
    return _('This display name will be shown to all users. If you leave it blank, your first and last name will be shown. If those are blank too, then your username will be shown.')
コード例 #24
0
ファイル: apps.py プロジェクト: hpoul/sct-communitytools
    def ready(self):
        from sphene.community import sphsettings
        from sphene.community.sphutils import add_setting_defaults
        from django.conf import settings

        post_migrate.connect(init_data, sender=self)

        add_setting_defaults({
            'board_count_views': True,
            'board_heat_days': 30,
            'board_heat_post_threshold': 10,
            'board_heat_view_threshold': 100,
            'board_heat_calculator': 'sphene.sphboard.models.calculate_heat',

            # Defines if the 'Notify Me' checkbox should be selected by default.
            'board_default_notifyme': True,

            # How long a user is allowed to edit his post in seconds.
            # -1: forever,
            # 0: never
            'board_edit_timeout': -1,  # 30 * 60,

            # How long a user is allowed to hide his post in seconds.
            # -1: forever,
            # 0: never
            'board_hide_timeout': -1,  # 30 * 60,

            # Timeout for the rendered body in the cache
            # Default 6 hours
            'board_body_cache_timeout': 6 * 3600,
            'board_signature_cache_timeout': 6 * 3600,
            'board_signature_required_post_count': 0,
            'board_no_limits_users': [],
            'board_authorinfo_cache_timeout': 6 * 3600,

            # See http://code.djangoproject.com/ticket/4789
            # When activating this setting, select_related() will not be used.
            'workaround_select_related_bug': False,

            'board_post_paging': 10,

            # Allow users to attach files to their posts ?
            'board_allow_attachments': True,

            # Pass the board and blog posts through the wiki camel case
            # markup. This will allow wiki links to be automatically placed
            # into the posts. It is better to turn this off and use the
            # sph extended BBCODE wiki label.
            'board_auto_wiki_link_enabled': True,
            # default location of emoticons
            'board_emoticons_root': settings.STATIC_URL + 'sphene/emoticons/',
            'board_emoticons_list': {
                '0:-)': 'angel.gif',
                'O:-)': 'angel.gif',
                ':angel:': 'angel.gif',
                ':)': 'smile.gif',
                ':(': 'sad.gif',
                ':D': 'grin.gif',
                ':p': 'tongue.gif',
                ';)': 'wink.gif',
                ':-)': 'smile.gif',
                ':-(': 'sad.gif',
                ':-D': 'grin.gif',
                ':-P': 'tongue.gif',
                ':-p': 'tongue.gif',
                ':-/': 'unsure.gif',
                ':-\\': 'unsure.gif',
                ';-)': 'wink.gif',
                ':-$': 'confused.gif',
                ':-S': 'confused.gif',
                'B-)': 'cool.gif',
                ':lol:': 'lol.gif',
                ':batman:': 'batman.gif',
                ':rolleyes:': 'rolleyes.gif',
                ':icymad:': 'bluemad.gif',
                ':mad:': 'mad.gif',
                ':crying:': 'crying.gif',
                ':eek:': 'eek.gif',
                ':eyebrow:': 'eyebrow.gif',
                ':grim:': 'grim_reaper.gif',
                ':idea:': 'idea.gif',
                ':rotfl:': 'rotfl.gif',
                ':shifty:': 'shifty.gif',
                ':sleep:': 'sleep.gif',
                ':thinking:': 'thinking.gif',
                ':wave:': 'wave.gif',
                ':bow:': 'bow.gif',
                ':sheep:': 'sheep.gif',
                ':santa:': 'santaclaus.gif',
                ':anvil:': 'anvil.gif',
                ':bandit:': 'bandit.gif',
                ':chop:': 'behead.gif',
                ':biggun:': 'biggun.gif',
                ':mouthful:': 'blowingup,gif',
                ':gun:': 'bluekillsred.gif',
                ':box:': 'boxing.gif',
                ':gallows:': 'hanged.gif',
                ':jedi:': 'lightsaber1.gif',
                ':bosh:': 'mallet1.gif',
                ':saw:': 'saw.gif',
                ':stupid:': 'youarestupid.gif',
            },

            # default tag used when rendering user signatures in posts
            'board_signature_tag': '<div class="signature">%(signature)s</div>',

            # default link in board posts
            'board_post_link': '<a href="%(url)s">%(text)s</a>',

            'board_attachments_upload_to': 'var/sphene/sphwiki/attachment/%Y/%m/%d',

            'board_slugify_links': True,

            # Display the reply form directly below a thread instead of just a 'Post Reply' link.
            'board_quick_reply': False,

            # Activates the experimental WYSIWYG editor -
            #   only if 'bbcode' is the only markup choice.
            # If you are using it, please provide feedback in the
            # forums at http://sct.spene.net !
            'board_wysiwyg': False,
            # This options let users test the wysiwyg editor by appending
            # ?wysiwyg=1 to the post URL. (I just added it so it can be seen on
            # sct.sphene.net and tested by users.)
            'board_wysiwyg_testing': False,
        })

        styleincludes = sphsettings.get_sph_setting('community_styleincludes', [])
        styleincludes.append(settings.STATIC_URL + 'sphene/sphboard/styles/base.css')
        sphsettings.set_sph_setting('community_styleincludes', styleincludes)
コード例 #25
0
def get_sph_setting(name, default_value = None):
    return sphsettings.get_sph_setting(name, default_value)
コード例 #26
0
ファイル: __init__.py プロジェクト: hmm/sct-communitytools
    },

    # default tag used when rendering user signatures in posts
    'board_signature_tag':'<div class="signature">%(signature)s</div>',

    # default link in board posts
    'board_post_link':'<a href="%(url)s">%(text)s</a>',

    'board_attachments_upload_to': 'var/sphene/sphwiki/attachment/%Y/%m/%d',

    'board_slugify_links': True,

    # Display the reply form directly below a thread instead of just a 'Post Reply' link.
    'board_quick_reply': False,

    # Activates the experimental WYSIWYG editor -
    #   only if 'bbcode' is the only markup choice.
    # If you are using it, please provide feedback in the
    # forums at http://sct.spene.net !
    'board_wysiwyg': False,
    # This options let users test the wysiwyg editor by appending
    # ?wysiwyg=1 to the post URL. (I just added it so it can be seen on
    # sct.sphene.net and tested by users.)
    'board_wysiwyg_testing': False,
    })


styleincludes = sphsettings.get_sph_setting( 'community_styleincludes', [])
styleincludes.append(settings.STATIC_URL + 'sphene/sphboard/styles/base.css')
sphsettings.set_sph_setting( 'community_styleincludes', styleincludes )
コード例 #27
0
def get_user_displayname_help():
    if get_sph_setting( 'community_user_displayname_fallback' ) == 'username':
        return _('This display name will be shown to all users. If you leave it blank then your username will be shown.')
    return _('This display name will be shown to all users. If you leave it blank, your first and last name will be shown. If those are blank too, then your username will be shown.')
コード例 #28
0
ファイル: views.py プロジェクト: sunilpatelmca/dishnine
 def __init__(self, *args, **kwargs):
     super(RegisterEmailAddress, self).__init__(*args, **kwargs)
     if not sphutils.has_captcha_support() or not sphsettings.get_sph_setting('community_register_require_captcha', False):
         del self.fields['captcha']
コード例 #29
0
ファイル: models.py プロジェクト: sunilpatelmca/dishnine
    return ret


def get_category_name(post):
    return post.category.name
get_category_name.name = 'category'

def get_category_id(post):
    return post.category.id
get_category_id.name = 'category_id'

def get_group_id(post):
    return post.category.group.id
get_group_id.name = 'group_id'

searchboard_post_index = sphsettings.get_sph_setting('sphsearchboard_post_index', '/var/cache/sct/postindex/')

if not os.path.isdir(searchboard_post_index):
    os.makedirs(searchboard_post_index)

post_index = Indexer(
    path = searchboard_post_index,

    model = Post,

    fields = [('subject', 20), 'body'],

    tags = [
        ('subject', 'subject', 20),
        ('date', 'postdate'),
        ('category', 'category.name'),
コード例 #30
0
    def ready(self):
        from sphene.community import sphsettings
        from sphene.community.sphutils import add_setting_defaults
        from django.conf import settings

        post_migrate.connect(init_data, sender=self)

        add_setting_defaults({
            'board_count_views': True,
            'board_heat_days': 30,
            'board_heat_post_threshold': 10,
            'board_heat_view_threshold': 100,
            'board_heat_calculator': 'sphene.sphboard.models.calculate_heat',

            # Defines if the 'Notify Me' checkbox should be selected by default.
            'board_default_notifyme': True,

            # How long a user is allowed to edit his post in seconds.
            # -1: forever,
            # 0: never
            'board_edit_timeout': -1,  # 30 * 60,

            # How long a user is allowed to hide his post in seconds.
            # -1: forever,
            # 0: never
            'board_hide_timeout': -1,  # 30 * 60,

            # Timeout for the rendered body in the cache
            # Default 6 hours
            'board_body_cache_timeout': 6 * 3600,
            'board_signature_cache_timeout': 6 * 3600,
            'board_signature_required_post_count': 0,
            'board_no_limits_users': [],
            'board_authorinfo_cache_timeout': 6 * 3600,

            # See http://code.djangoproject.com/ticket/4789
            # When activating this setting, select_related() will not be used.
            'workaround_select_related_bug': False,
            'board_post_paging': 10,

            # Allow users to attach files to their posts ?
            'board_allow_attachments': True,

            # Pass the board and blog posts through the wiki camel case
            # markup. This will allow wiki links to be automatically placed
            # into the posts. It is better to turn this off and use the
            # sph extended BBCODE wiki label.
            'board_auto_wiki_link_enabled': True,
            # default location of emoticons
            'board_emoticons_root': settings.STATIC_URL + 'sphene/emoticons/',
            'board_emoticons_list': {
                '0:-)': 'angel.gif',
                'O:-)': 'angel.gif',
                ':angel:': 'angel.gif',
                ':)': 'smile.gif',
                ':(': 'sad.gif',
                ':D': 'grin.gif',
                ':p': 'tongue.gif',
                ';)': 'wink.gif',
                ':-)': 'smile.gif',
                ':-(': 'sad.gif',
                ':-D': 'grin.gif',
                ':-P': 'tongue.gif',
                ':-p': 'tongue.gif',
                ':-/': 'unsure.gif',
                ':-\\': 'unsure.gif',
                ';-)': 'wink.gif',
                ':-$': 'confused.gif',
                ':-S': 'confused.gif',
                'B-)': 'cool.gif',
                ':lol:': 'lol.gif',
                ':batman:': 'batman.gif',
                ':rolleyes:': 'rolleyes.gif',
                ':icymad:': 'bluemad.gif',
                ':mad:': 'mad.gif',
                ':crying:': 'crying.gif',
                ':eek:': 'eek.gif',
                ':eyebrow:': 'eyebrow.gif',
                ':grim:': 'grim_reaper.gif',
                ':idea:': 'idea.gif',
                ':rotfl:': 'rotfl.gif',
                ':shifty:': 'shifty.gif',
                ':sleep:': 'sleep.gif',
                ':thinking:': 'thinking.gif',
                ':wave:': 'wave.gif',
                ':bow:': 'bow.gif',
                ':sheep:': 'sheep.gif',
                ':santa:': 'santaclaus.gif',
                ':anvil:': 'anvil.gif',
                ':bandit:': 'bandit.gif',
                ':chop:': 'behead.gif',
                ':biggun:': 'biggun.gif',
                ':mouthful:': 'blowingup,gif',
                ':gun:': 'bluekillsred.gif',
                ':box:': 'boxing.gif',
                ':gallows:': 'hanged.gif',
                ':jedi:': 'lightsaber1.gif',
                ':bosh:': 'mallet1.gif',
                ':saw:': 'saw.gif',
                ':stupid:': 'youarestupid.gif',
            },

            # default tag used when rendering user signatures in posts
            'board_signature_tag':
            '<div class="signature">%(signature)s</div>',

            # default link in board posts
            'board_post_link': '<a href="%(url)s">%(text)s</a>',
            'board_attachments_upload_to':
            'var/sphene/sphwiki/attachment/%Y/%m/%d',
            'board_slugify_links': True,

            # Display the reply form directly below a thread instead of just a 'Post Reply' link.
            'board_quick_reply': False,

            # Activates the experimental WYSIWYG editor -
            #   only if 'bbcode' is the only markup choice.
            # If you are using it, please provide feedback in the
            # forums at http://sct.spene.net !
            'board_wysiwyg': False,
            # This options let users test the wysiwyg editor by appending
            # ?wysiwyg=1 to the post URL. (I just added it so it can be seen on
            # sct.sphene.net and tested by users.)
            'board_wysiwyg_testing': False,
        })

        styleincludes = sphsettings.get_sph_setting('community_styleincludes',
                                                    [])
        styleincludes.append(settings.STATIC_URL +
                             'sphene/sphboard/styles/base.css')
        sphsettings.set_sph_setting('community_styleincludes', styleincludes)
コード例 #31
0
ファイル: sphutils.py プロジェクト: sunilpatelmca/dishnine
def get_sph_setting(name, default_value=None):
    return sphsettings.get_sph_setting(name, default_value)
コード例 #32
0

def get_category_id(post):
    return post.category.id


get_category_id.name = 'category_id'


def get_group_id(post):
    return post.category.group.id


get_group_id.name = 'group_id'

searchboard_post_index = sphsettings.get_sph_setting(
    'sphsearchboard_post_index', '/var/cache/sct/postindex/')

if not os.path.isdir(searchboard_post_index):
    os.makedirs(searchboard_post_index)

post_index = Indexer(path=searchboard_post_index,
                     model=Post,
                     fields=[('subject', 20), 'body'],
                     tags=[
                         ('subject', 'subject', 20),
                         ('date', 'postdate'),
                         ('category', 'category.name'),
                         ('post_id', 'id'),
                         ('category_id', 'category.id'),
                         ('group_id', 'category.group.id'),
                     ])
コード例 #33
0
    6 * 3600,
    'board_signature_cache_timeout':
    6 * 3600,
    'board_authorinfo_cache_timeout':
    6 * 3600,

    # See http://code.djangoproject.com/ticket/4789
    # When activating this setting, select_related() will not be used.
    'workaround_select_related_bug':
    False,
    'board_post_paging':
    10,

    # Allow users to attach files to their posts ?
    'board_allow_attachments':
    True,

    # Pass the board and blog posts through the wiki camel case
    # markup. This will allow wiki links to be automatically placed
    # into the posts. It is better to turn this off and use the
    # sph extended BBCODE wiki label.
    'board_auto_wiki_link_enabled':
    True,
    'board_attachments_upload_to':
    'var/sphene/sphwiki/attachment/%Y/%m/%d',
})

styleincludes = sphsettings.get_sph_setting('community_styleincludes', [])
styleincludes.append(settings.MEDIA_URL + 'sphene/sphboard/styles/base.css')
sphsettings.set_sph_setting('community_styleincludes', styleincludes)
コード例 #34
0
 def __init__(self, *args, **kwargs):
     super(RegisterEmailAddress, self).__init__(*args, **kwargs)
     if not sphutils.has_captcha_support(
     ) or not sphsettings.get_sph_setting(
             'community_register_require_captcha', False):
         del self.fields['captcha']