예제 #1
0
from adhocracy.lib.helpers.site_helper import base_url, velruse_url
from adhocracy.lib.text import (render, markdown_to_plain_text,
                                html_to_plain_text)
from adhocracy.lib.helpers import velruse_helper as velruse
from adhocracy.lib.watchlist import make_watch, find_watch
from adhocracy import model, static
from adhocracy.i18n import countdown_time, format_date
from adhocracy.i18n import date_tag
from adhocracy.i18n import datetime_tag
from adhocracy.model.text import Text

log = logging.getLogger(__name__)

flash = _Flash()
recaptcha = recaptcha.Recaptcha()
need = FanstaticNeedHelper(static)


def allow_user_registration():
    return (config.get_bool('adhocracy.allow_registration')
            and not config.get_bool('adhocracy.readonly'))


def sorted_flash_messages():
    '''
    Return the flash messages sorted by priority, keeping
    the order.
    '''
    order = ['error', 'warning', 'success', 'notice']
    sorted_ = []
    unsorted = flash.pop_messages()
예제 #2
0
 def test_resource(self):
     from adhocracy.lib.helpers.fanstatic_helper import FanstaticNeedHelper
     import fanstatic_dummy_module
     need = FanstaticNeedHelper(fanstatic_dummy_module)
     result = need.resource
     self.assertEqual(result, 'needed resource')
예제 #3
0
 def test_not_group_or_resource(self):
     from adhocracy.lib.helpers.fanstatic_helper import FanstaticNeedHelper
     import fanstatic_dummy_module
     need = FanstaticNeedHelper(fanstatic_dummy_module)
     self.assertRaises(ValueError, getattr, need, 'library')
예제 #4
0
 def test_non_existent_resource(self):
     from adhocracy.lib.helpers.fanstatic_helper import FanstaticNeedHelper
     import fanstatic_dummy_module
     need = FanstaticNeedHelper(fanstatic_dummy_module)
     self.assertRaises(AttributeError, getattr, need, 'nonexistant')
예제 #5
0
 def test_group(self):
     from adhocracy.lib.helpers.fanstatic_helper import FanstaticNeedHelper
     import fanstatic_dummy_module
     need = FanstaticNeedHelper(fanstatic_dummy_module)
     result = need.group
     self.assertEqual(result, 'needed group')