示例#1
0
 def test_validation_fails_for_overlapping_positions3(self):
     Position.objects.create(category=self.category,
                             name='position-name',
                             text='some text',
                             active_from=utc_localize(datetime(
                                 2010, 10, 10)))
     p = Position(category=self.category,
                  name='position-name',
                  text='other text',
                  active_till=utc_localize(datetime(2010, 10, 11)))
     tools.assert_raises(ValidationError, p.full_clean)
示例#2
0
 def test_validation_passes_for_nonoverlapping_positions(self):
     Position.objects.create(category=self.category,
                             name='position-name',
                             text='some text',
                             active_till=utc_localize(
                                 datetime(2010, 10, 10, 10, 10, 10)))
     p = Position(category=self.category,
                  name='position-name',
                  text='other text',
                  active_from=utc_localize(
                      datetime(2010, 10, 10, 10, 10, 10)))
     p.full_clean()
示例#3
0
def create_and_publish_gallery(case):
    case.publishable = Gallery.objects.create(
        title=u'First Gallery',
        slug=u'first-gallery',
        description=u'Some\nlonger\ntext',
        category=case.category_nested,
        content=u'Some\neven\nlonger\ntext',
        publish_from=utc_localize(datetime(2008, 1, 10)),
        published=True
    )

    case.p1 = create_photo(case)
    case.p2 = create_photo(case, slug='another-photo')

    case.galitem = case.publishable.galleryitem_set.create(
        photo=case.p1,
        order=0
    )

    case.galitem2 = case.publishable.galleryitem_set.create(
        photo=case.p2,
        order=1
    )

    case.galitem3 = case.publishable.galleryitem_set.create(
        photo=case.p1,
        order=2
    )
 def _create_comment(self):
     " Util method to create and return a new commnt. "
     return create_comment(
         self.publishable,
         self.publishable.content_type,
         user_name='kvbik',
         submit_date=utc_localize(datetime(2010, 10, 10, 10, 10, 10))
     )
示例#5
0
文件: conf.py 项目: MikeLing/ella
CACHE_TIMEOUT = 10 * 60
CACHE_TIMEOUT_LONG = 60 * 60

DOUBLE_RENDER = False
DOUBLE_RENDER_EXCLUDE_URLS = None

APP_DATA_CLASSES = {}

# Box
BOX_INFO = 'ella.core.box.BOX_INFO'
MEDIA_KEY = 'ella.core.box.MEDIA_KEY'

# Publishing configuration
CATEGORY_LISTINGS_PAGINATE_BY = 20
CATEGORY_NO_HOME_LISTINGS = False
PUBLISH_FROM_WHEN_EMPTY = utc_localize(datetime(3000, 1, 1))

RELATED_FINDERS = {
    'default': (
        'ella.core.related_finders.directly_related',
        'ella.core.related_finders.related_by_category',
    ),
    'directly': (
        'ella.core.related_finders.directly_related',
    )
}

LISTING_HANDLERS = {
    'default': 'ella.core.managers.ModelListingHandler',
}
示例#6
0
 def test_validation_passes_for_nonoverlapping_positions(self):
     Position.objects.create(category=self.category, name='position-name', text='some text', active_till=utc_localize(datetime(2010, 10, 10, 10, 10, 10)))
     p = Position(category=self.category, name='position-name', text='other text', active_from=utc_localize(datetime(2010, 10, 10, 10, 10, 10)))
     p.full_clean()
示例#7
0
 def test_validation_fails_for_overlapping_positions3(self):
     Position.objects.create(category=self.category, name='position-name', text='some text', active_from=utc_localize(datetime(2010, 10, 10)))
     p = Position(category=self.category, name='position-name', text='other text', active_till=utc_localize(datetime(2010, 10, 11)))
     tools.assert_raises(ValidationError, p.full_clean)
示例#8
0
文件: conf.py 项目: Pheox/ella
CACHE_TIMEOUT = 10 * 60
CACHE_TIMEOUT_LONG = 60 * 60

DOUBLE_RENDER = False
DOUBLE_RENDER_EXCLUDE_URLS = None

APP_DATA_CLASSES = {}

# Box
BOX_INFO = 'ella.core.box.BOX_INFO'
MEDIA_KEY = 'ella.core.box.MEDIA_KEY'

# Publishing configuration
CATEGORY_LISTINGS_PAGINATE_BY = 20
CATEGORY_NO_HOME_LISTINGS = False
PUBLISH_FROM_WHEN_EMPTY = utc_localize(datetime(3000, 1, 1))

RELATED_FINDERS = {
    'default': (
        'ella.core.related_finders.directly_related',
        'ella.core.related_finders.related_by_category',
    ),
    'directly': ('ella.core.related_finders.directly_related', )
}

LISTING_HANDLERS = {
    'default': 'ella.core.managers.ModelListingHandler',
}

# Category settings
CATEGORY_TEMPLATES = (('category.html', gettext('default (category.html)')), )
示例#9
0
    from io import BytesIO
except ImportError:
    from cStringIO import StringIO as BytesIO

from django.utils import six
from django.conf import settings
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.template.defaultfilters import slugify

from ella.core.models import Category, Publishable, Listing
# choose Article as an example publishable
from ella.articles.models import Article
from ella.photos.models import Photo
from ella.utils.timezone import utc_localize

default_time = utc_localize(datetime(2008, 1, 10))


def create_category(title, tree_parent=None, **kwargs):
    defaults = {
        'site_id': getattr(settings, "SITE_ID", 1),
        'slug': slugify(title),
    }
    defaults.update(kwargs)
    if isinstance(tree_parent, six.string_types):
        tree_parent = Category.objects.get_by_tree_path(tree_parent)
    cat, created = Category.objects.get_or_create(tree_parent=tree_parent, title=title, defaults=defaults)
    return cat


def create_basic_categories(case):
    def test_aa(self):
        day = datetime.now().strftime('%Y%m%d')
        create_comment(self.publishable, self.publishable.content_type, user_name='kvbik', submit_date=utc_localize(datetime(2010, 10, 10, 10, 10, 10)))
        ct_id = self.publishable.content_type_id
        tools.assert_equals(set([
            'slidingccount:WINDOWS',
            'slidingccount:KEYS',

            'comcount:2',
            'lastcom:2',
            'slidingccount:2',

            'comcount:c:1',
            'comcount:c:2',
            'lastcom:c:1',
            'lastcom:c:2',
            'slidingccount:c:1',
            'slidingccount:c:2',

            'lastcom:d:1',
            'lastcom:d:2',
            'comcount:d:1',
            'comcount:d:2',
            'slidingccount:d:1',
            'slidingccount:d:2',

            'lastcom:ct:%d' % ct_id,
            'comcount:ct:%d' % ct_id,
            'slidingccount:ct:%d' % ct_id,


            'lastcom:pub:%d:1' % ct_id,
            'comcount:pub:%d:1' % ct_id,


            'slidingccount:2:%s' % day,
            'slidingccount:c:1:%s' % day,
            'slidingccount:c:2:%s' % day,
            'slidingccount:d:1:%s' % day,
            'slidingccount:d:2:%s' % day,
            'slidingccount:ct:%d:%s' % (ct_id, day),

        ]), set(client.keys('*')))

        if use_tz:
            # timestamps are stored in utc time
            tstamp = '1286705410.0'
        else:
            tstamp = '1286698210.0'
        tools.assert_equals({'submit_date': tstamp, 'user_id': '', 'username': '******', 'comment': '', 'url': ''}, client.hgetall('lastcom:pub:%d:1' % ct_id))
        tools.assert_equals('1', client.get('comcount:pub:%d:1' % ct_id))