mirror of
https://github.com/QingdaoU/Spirit.git
synced 2024-12-29 16:02:04 +00:00
moved all apps one level up
This commit is contained in:
parent
e88e3b5b67
commit
ae5904cfad
34
runtests.py
34
runtests.py
@ -33,23 +33,23 @@ def run_tests():
|
||||
test_runner = DiscoverRunner()
|
||||
# todo: remove in spirit 0.4
|
||||
failures = test_runner.run_tests([
|
||||
"spirit.apps.admin",
|
||||
"spirit.apps.category",
|
||||
"spirit.apps.comment",
|
||||
"spirit.apps.comment.bookmark",
|
||||
"spirit.apps.comment.flag",
|
||||
"spirit.apps.comment.history",
|
||||
"spirit.apps.comment.like",
|
||||
"spirit.apps.core",
|
||||
"spirit.apps.search",
|
||||
"spirit.apps.topic",
|
||||
"spirit.apps.topic.favorite",
|
||||
"spirit.apps.topic.moderate",
|
||||
"spirit.apps.topic.notification",
|
||||
"spirit.apps.topic.poll",
|
||||
"spirit.apps.topic.private",
|
||||
"spirit.apps.topic.unread",
|
||||
"spirit.apps.user",
|
||||
"spirit.admin",
|
||||
"spirit.category",
|
||||
"spirit.comment",
|
||||
"spirit.comment.bookmark",
|
||||
"spirit.comment.flag",
|
||||
"spirit.comment.history",
|
||||
"spirit.comment.like",
|
||||
"spirit.core",
|
||||
"spirit.search",
|
||||
"spirit.topic",
|
||||
"spirit.topic.favorite",
|
||||
"spirit.topic.moderate",
|
||||
"spirit.topic.notification",
|
||||
"spirit.topic.poll",
|
||||
"spirit.topic.private",
|
||||
"spirit.topic.unread",
|
||||
"spirit.user",
|
||||
])
|
||||
sys.exit(failures)
|
||||
|
||||
|
@ -9,19 +9,19 @@ from django.core.exceptions import PermissionDenied
|
||||
from django.contrib.auth import get_user_model
|
||||
from djconfig.utils import override_djconfig
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.apps.admin.views import dashboard
|
||||
from spirit.apps.admin import views
|
||||
from spirit.apps.category.admin import views as category_views
|
||||
from spirit.apps.comment.flag.admin import views as flag_views
|
||||
from spirit.apps.topic.admin import views as topic_views
|
||||
from spirit.apps.user.admin import views as user_views
|
||||
from spirit.apps.category.models import Category
|
||||
from spirit.apps.comment.flag.models import CommentFlag, Flag
|
||||
from spirit.apps.admin.forms import BasicConfigForm
|
||||
from spirit.apps.comment.flag.admin.forms import CommentFlagForm
|
||||
from spirit.apps.user.admin.forms import UserForm, UserProfileForm
|
||||
from spirit.apps.category.admin.forms import CategoryForm
|
||||
from spirit.core.tests import utils
|
||||
from spirit.admin.views import dashboard
|
||||
from spirit.admin import views
|
||||
from spirit.category.admin import views as category_views
|
||||
from spirit.comment.flag.admin import views as flag_views
|
||||
from spirit.topic.admin import views as topic_views
|
||||
from spirit.user.admin import views as user_views
|
||||
from spirit.category.models import Category
|
||||
from spirit.comment.flag.models import CommentFlag, Flag
|
||||
from spirit.admin.forms import BasicConfigForm
|
||||
from spirit.comment.flag.admin.forms import CommentFlagForm
|
||||
from spirit.user.admin.forms import UserForm, UserProfileForm
|
||||
from spirit.category.admin.forms import CategoryForm
|
||||
|
||||
User = get_user_model()
|
||||
|
23
spirit/admin/urls.py
Normal file
23
spirit/admin/urls.py
Normal file
@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import include, url
|
||||
|
||||
from . import views
|
||||
import spirit.category.admin.urls
|
||||
import spirit.comment.flag.admin.urls
|
||||
import spirit.topic.admin.urls
|
||||
import spirit.user.admin.urls
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.dashboard, name='admin'),
|
||||
url(r'^dashboard/$', views.dashboard, name='admin-dashboard'),
|
||||
url(r'^config/$', views.config_basic, name='admin-config-basic'),
|
||||
|
||||
url(r'^category/', include(spirit.category.admin.urls)),
|
||||
url(r'^comment/flag/', include(spirit.comment.flag.admin.urls)),
|
||||
url(r'^topic/', include(spirit.topic.admin.urls)),
|
||||
url(r'^user/', include(spirit.user.admin.urls)),
|
||||
]
|
@ -13,7 +13,7 @@ from ..comment.flag.models import CommentFlag
|
||||
from ..comment.like.models import CommentLike
|
||||
from ..comment.models import Comment
|
||||
from ..topic.models import Topic
|
||||
from spirit.apps.core.utils.decorators import administrator_required
|
||||
from spirit.core.utils.decorators import administrator_required
|
||||
from .forms import BasicConfigForm
|
||||
|
||||
User = get_user_model()
|
@ -17,7 +17,7 @@ class SpiritConfig(AppConfig):
|
||||
|
||||
def register_config(self):
|
||||
import djconfig
|
||||
from spirit.apps.admin.forms import BasicConfigForm
|
||||
from spirit.admin.forms import BasicConfigForm
|
||||
|
||||
djconfig.register(BasicConfigForm)
|
||||
|
@ -1,23 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import include, url
|
||||
|
||||
from . import views
|
||||
import spirit.apps.category.admin.urls
|
||||
import spirit.apps.comment.flag.admin.urls
|
||||
import spirit.apps.topic.admin.urls
|
||||
import spirit.apps.user.admin.urls
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.dashboard, name='admin'),
|
||||
url(r'^dashboard/$', views.dashboard, name='admin-dashboard'),
|
||||
url(r'^config/$', views.config_basic, name='admin-config-basic'),
|
||||
|
||||
url(r'^category/', include(spirit.apps.category.admin.urls)),
|
||||
url(r'^comment/flag/', include(spirit.apps.comment.flag.admin.urls)),
|
||||
url(r'^topic/', include(spirit.apps.topic.admin.urls)),
|
||||
url(r'^user/', include(spirit.apps.user.admin.urls)),
|
||||
]
|
@ -1,5 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from spirit.apps.core.utils.ratelimit.ratelimit import RateLimit
|
||||
|
||||
__all__ = ['RateLimit']
|
@ -8,7 +8,7 @@ from django.core.urlresolvers import reverse
|
||||
from django.contrib import messages
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from spirit.apps.core.utils.decorators import administrator_required
|
||||
from spirit.core.utils.decorators import administrator_required
|
||||
from ..models import Category
|
||||
from .forms import CategoryForm
|
||||
|
@ -9,7 +9,7 @@ from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
from .managers import CategoryQuerySet
|
||||
from spirit.apps.core.utils.models import AutoSlugField
|
||||
from spirit.core.utils.models import AutoSlugField
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
@ -10,9 +10,9 @@ from django.core.cache import cache
|
||||
from django.utils import timezone
|
||||
from djconfig.utils import override_djconfig
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.apps.topic.models import Topic
|
||||
from spirit.apps.comment.bookmark.models import CommentBookmark
|
||||
from spirit.core.tests import utils
|
||||
from spirit.topic.models import Topic
|
||||
from spirit.comment.bookmark.models import CommentBookmark
|
||||
|
||||
|
||||
class CategoryViewTest(TestCase):
|
@ -11,7 +11,7 @@ from django.shortcuts import get_object_or_404
|
||||
|
||||
from djconfig import config
|
||||
|
||||
from spirit.apps.core.utils.paginator import yt_paginate
|
||||
from spirit.core.utils.paginator import yt_paginate
|
||||
from ..topic.models import Topic
|
||||
from .models import Category
|
||||
|
@ -7,7 +7,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from djconfig import config
|
||||
import spirit.apps.core.utils.paginator
|
||||
import spirit.core.utils.paginator
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
@ -29,7 +29,7 @@ class CommentBookmark(models.Model):
|
||||
% (self.user.username, self.topic.title, self.comment_number)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return spirit.apps.core.utils.paginator.get_url(self.topic.get_absolute_url(),
|
||||
return spirit.core.utils.paginator.get_url(self.topic.get_absolute_url(),
|
||||
self.comment_number,
|
||||
config.comments_per_page,
|
||||
'page')
|
@ -8,10 +8,10 @@ from django.template import Template, Context
|
||||
from django.core.cache import cache
|
||||
from djconfig import config
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.apps.comment.bookmark.models import CommentBookmark
|
||||
from spirit.apps.topic.signals import topic_viewed
|
||||
from spirit.apps.comment.bookmark.forms import BookmarkForm
|
||||
from spirit.core.tests import utils
|
||||
from spirit.comment.bookmark.models import CommentBookmark
|
||||
from spirit.topic.signals import topic_viewed
|
||||
from spirit.comment.bookmark.forms import BookmarkForm
|
||||
|
||||
|
||||
class CommentBookmarkViewTest(TestCase):
|
@ -8,7 +8,7 @@ from django.shortcuts import redirect
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.http import Http404
|
||||
|
||||
from spirit.apps.core.utils import json_response
|
||||
from spirit.core.utils import json_response
|
||||
from ...topic.models import Topic
|
||||
from .forms import BookmarkForm
|
||||
|
@ -10,8 +10,8 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
from djconfig import config
|
||||
|
||||
from spirit.apps.core.utils.paginator import yt_paginate
|
||||
from spirit.apps.core.utils.decorators import administrator_required
|
||||
from spirit.core.utils.paginator import yt_paginate
|
||||
from spirit.core.utils.decorators import administrator_required
|
||||
from .forms import CommentFlagForm
|
||||
from ..models import CommentFlag, Flag
|
||||
|
@ -6,9 +6,9 @@ from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.cache import cache
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.apps.comment.flag.models import Flag, CommentFlag
|
||||
from spirit.apps.comment.flag.forms import FlagForm
|
||||
from spirit.core.tests import utils
|
||||
from spirit.comment.flag.models import Flag, CommentFlag
|
||||
from spirit.comment.flag.forms import FlagForm
|
||||
|
||||
|
||||
class FlagViewTest(TestCase):
|
@ -10,8 +10,8 @@ from django import forms
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import spirit.apps.core.utils
|
||||
from spirit.apps.core.utils.markdown import Markdown
|
||||
import spirit.core.utils
|
||||
from spirit.core.utils.markdown import Markdown
|
||||
from .models import Comment
|
||||
from ..topic.models import Topic
|
||||
|
||||
@ -92,7 +92,7 @@ class CommentImageForm(forms.Form):
|
||||
upload_to = os.path.join('spirit', 'images', str(self.user.pk))
|
||||
image.url = os.path.join(settings.MEDIA_URL, upload_to, image.name).replace("\\", "/")
|
||||
media_path = os.path.join(settings.MEDIA_ROOT, upload_to)
|
||||
spirit.apps.core.utils.mkdir_p(media_path)
|
||||
spirit.core.utils.mkdir_p(media_path)
|
||||
|
||||
with open(os.path.join(media_path, image.name), 'wb') as fh:
|
||||
image.seek(0)
|
@ -7,9 +7,9 @@ from django.core.urlresolvers import reverse
|
||||
from django.core.cache import cache
|
||||
from djconfig.utils import override_djconfig
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.apps.comment.history.models import CommentHistory
|
||||
from spirit.apps.comment.signals import comment_pre_update, comment_post_update
|
||||
from spirit.core.tests import utils
|
||||
from spirit.comment.history.models import CommentHistory
|
||||
from spirit.comment.signals import comment_pre_update, comment_post_update
|
||||
|
||||
|
||||
class CommentHistoryViewTest(TestCase):
|
@ -8,7 +8,7 @@ from django.shortcuts import render, get_object_or_404
|
||||
|
||||
from djconfig import config
|
||||
|
||||
from spirit.apps.core.utils.paginator import yt_paginate
|
||||
from spirit.core.utils.paginator import yt_paginate
|
||||
from .models import CommentHistory
|
||||
from ..models import Comment
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from spirit.apps.core.tags.registry import register
|
||||
from spirit.core.tags.registry import register
|
||||
from .forms import LikeForm
|
||||
|
||||
|
@ -7,10 +7,10 @@ from django.core.urlresolvers import reverse
|
||||
from django.template import Template, Context
|
||||
from django.core.cache import cache
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.apps.comment.like.models import CommentLike
|
||||
from spirit.apps.comment.like.forms import LikeForm
|
||||
from spirit.apps.comment.like.tags import render_like_form
|
||||
from spirit.core.tests import utils
|
||||
from spirit.comment.like.models import CommentLike
|
||||
from spirit.comment.like.forms import LikeForm
|
||||
from spirit.comment.like.tags import render_like_form
|
||||
|
||||
|
||||
class LikeViewTest(TestCase):
|
@ -6,7 +6,7 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from spirit.apps.core.utils import json_response
|
||||
from spirit.core.utils import json_response
|
||||
from ..models import Comment
|
||||
from .models import CommentLike
|
||||
from .forms import LikeForm
|
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from spirit.apps.core.tags.registry import register
|
||||
from spirit.core.tags.registry import register
|
||||
from .forms import CommentForm
|
||||
from .models import MOVED, CLOSED, UNCLOSED, PINNED, UNPINNED
|
||||
|
@ -16,18 +16,18 @@ from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.test.utils import override_settings
|
||||
from django.utils.six import BytesIO
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.apps.comment.models import Comment
|
||||
from spirit.apps.comment.like.signals import comment_like_post_create, comment_like_post_delete
|
||||
from spirit.apps.topic.moderate.signals import topic_post_moderate
|
||||
from spirit.apps.comment.forms import CommentForm, CommentMoveForm, CommentImageForm
|
||||
from spirit.apps.comment.signals import comment_post_update, comment_posted, comment_pre_update, comment_moved
|
||||
from spirit.apps.comment.tags import render_comments_form
|
||||
from spirit.apps.core.utils import markdown
|
||||
from spirit.apps.comment.views import delete as comment_delete
|
||||
from spirit.apps.topic.models import Topic
|
||||
from spirit.apps.category.models import Category
|
||||
from spirit.apps.user.models import UserProfile
|
||||
from spirit.core.tests import utils
|
||||
from spirit.comment.models import Comment
|
||||
from spirit.comment.like.signals import comment_like_post_create, comment_like_post_delete
|
||||
from spirit.topic.moderate.signals import topic_post_moderate
|
||||
from spirit.comment.forms import CommentForm, CommentMoveForm, CommentImageForm
|
||||
from spirit.comment.signals import comment_post_update, comment_posted, comment_pre_update, comment_moved
|
||||
from spirit.comment.tags import render_comments_form
|
||||
from spirit.core.utils import markdown
|
||||
from spirit.comment.views import delete as comment_delete
|
||||
from spirit.topic.models import Topic
|
||||
from spirit.category.models import Category
|
||||
from spirit.user.models import UserProfile
|
||||
|
||||
User = get_user_model()
|
||||
|
@ -10,13 +10,13 @@ from django.contrib import messages
|
||||
from django.http import Http404
|
||||
|
||||
from djconfig import config
|
||||
import spirit.apps.core.utils.paginator
|
||||
import spirit.core.utils.paginator
|
||||
|
||||
from spirit.apps.core.utils.ratelimit.decorators import ratelimit
|
||||
from spirit.apps.core.utils.decorators import moderator_required
|
||||
from spirit.apps.core.utils import markdown
|
||||
from spirit.apps.core.utils import render_form_errors
|
||||
from spirit.apps.core.utils import json_response
|
||||
from spirit.core.utils.ratelimit.decorators import ratelimit
|
||||
from spirit.core.utils.decorators import moderator_required
|
||||
from spirit.core.utils import markdown
|
||||
from spirit.core.utils import render_form_errors
|
||||
from spirit.core.utils import json_response
|
||||
from ..topic.models import Topic
|
||||
from .models import Comment
|
||||
from .forms import CommentForm, CommentMoveForm, CommentImageForm
|
||||
@ -112,7 +112,7 @@ def move(request, topic_id):
|
||||
def find(request, pk):
|
||||
comment = get_object_or_404(Comment, pk=pk)
|
||||
comment_number = Comment.objects.filter(topic=comment.topic, date__lte=comment.date).count()
|
||||
url = spirit.apps.core.utils.paginator.get_url(comment.topic.get_absolute_url(),
|
||||
url = spirit.core.utils.paginator.get_url(comment.topic.get_absolute_url(),
|
||||
comment_number,
|
||||
config.comments_per_page,
|
||||
'page')
|
@ -5,7 +5,7 @@ import math
|
||||
|
||||
from django.utils.encoding import smart_text
|
||||
|
||||
from spirit.apps.core.tags.registry import register
|
||||
from spirit.core.tags.registry import register
|
||||
|
||||
|
||||
@register.simple_tag()
|
@ -5,7 +5,7 @@ import hashlib
|
||||
|
||||
from django.utils.http import urlencode, urlquote
|
||||
|
||||
from spirit.apps.core.tags.registry import register
|
||||
from spirit.core.tags.registry import register
|
||||
|
||||
|
||||
@register.simple_tag()
|
@ -5,7 +5,7 @@ from collections import OrderedDict
|
||||
|
||||
from django.contrib.messages import constants
|
||||
|
||||
from spirit.apps.core.tags.registry import register
|
||||
from spirit.core.tags.registry import register
|
||||
|
||||
|
||||
TAGS = {
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
from django.template.loader import render_to_string
|
||||
from django.core.paginator import Page
|
||||
|
||||
from spirit.apps.core.tags.registry import register
|
||||
from spirit.core.tags.registry import register
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.utils.http import urlencode
|
||||
|
||||
from spirit.apps.core.tags.registry import register
|
||||
from spirit.core.tags.registry import register
|
||||
|
||||
|
||||
FACEBOOK_URL = "http://www.facebook.com/sharer.php?%s"
|
@ -7,7 +7,7 @@ from django.template import defaultfilters
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.timezone import is_aware, utc
|
||||
|
||||
from spirit.apps.core.tags.registry import register
|
||||
from spirit.core.tags.registry import register
|
||||
|
||||
|
||||
@register.filter(expects_localtime=True)
|
@ -2,13 +2,13 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from spirit.apps.comment import tags as comment
|
||||
from spirit.apps.comment.like import tags as comment_like
|
||||
from spirit.apps.search import tags as search
|
||||
from spirit.apps.topic.favorite import tags as topic_favorite
|
||||
from spirit.apps.topic.notification import tags as topic_notification
|
||||
from spirit.apps.topic.poll import tags as topic_poll
|
||||
from spirit.apps.topic.private import tags as topic_private
|
||||
from spirit.comment import tags as comment
|
||||
from spirit.comment.like import tags as comment_like
|
||||
from spirit.search import tags as search
|
||||
from spirit.topic.favorite import tags as topic_favorite
|
||||
from spirit.topic.notification import tags as topic_notification
|
||||
from spirit.topic.poll import tags as topic_poll
|
||||
from spirit.topic.private import tags as topic_private
|
||||
from ..tags import avatar
|
||||
from ..tags import gravatar
|
||||
from ..tags import messages
|
57
spirit/core/tests/migrations/0001_initial.py
Normal file
57
spirit/core/tests/migrations/0001_initial.py
Normal file
@ -0,0 +1,57 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
import spirit.core.utils.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AutoSlugBadPopulateFromModel',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('slug', spirit.core.utils.models.AutoSlugField(populate_from=b'bad')),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AutoSlugDefaultModel',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('slug', spirit.core.utils.models.AutoSlugField(default=b'foo')),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AutoSlugModel',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('slug', spirit.core.utils.models.AutoSlugField()),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='AutoSlugPopulateFromModel',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('title', models.CharField(max_length=255, blank=True)),
|
||||
('slug', spirit.core.utils.models.AutoSlugField(populate_from=b'title')),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
13
spirit/core/tests/models/__init__.py
Normal file
13
spirit/core/tests/models/__init__.py
Normal file
@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .auto_slug import (
|
||||
AutoSlugPopulateFromModel, AutoSlugModel,
|
||||
AutoSlugDefaultModel, AutoSlugBadPopulateFromModel
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
'AutoSlugPopulateFromModel', 'AutoSlugModel',
|
||||
'AutoSlugDefaultModel', 'AutoSlugBadPopulateFromModel'
|
||||
]
|
26
spirit/core/tests/models/auto_slug.py
Normal file
26
spirit/core/tests/models/auto_slug.py
Normal file
@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
|
||||
from spirit.core.utils.models import AutoSlugField
|
||||
|
||||
|
||||
class AutoSlugModel(models.Model):
|
||||
|
||||
slug = AutoSlugField(max_length=50)
|
||||
|
||||
|
||||
class AutoSlugDefaultModel(models.Model):
|
||||
|
||||
slug = AutoSlugField(max_length=50, default="foo")
|
||||
|
||||
|
||||
class AutoSlugPopulateFromModel(models.Model):
|
||||
|
||||
title = models.CharField(max_length=255, blank=True)
|
||||
slug = AutoSlugField(populate_from='title', max_length=50)
|
||||
|
||||
|
||||
class AutoSlugBadPopulateFromModel(models.Model):
|
||||
|
||||
slug = AutoSlugField(populate_from='bad', max_length=50)
|
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
from django.test import TestCase
|
||||
from django.template import Template, Context
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.core.tests import utils
|
||||
|
||||
|
||||
class GravatarTemplateTagTests(TestCase):
|
@ -24,19 +24,19 @@ from django.utils.timezone import utc
|
||||
from django.utils.http import urlunquote
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from spirit.apps.category.models import Category
|
||||
import spirit.apps.core.utils
|
||||
from spirit.apps.core.utils.forms import NestedModelChoiceField
|
||||
from spirit.apps.core.utils.timezone import TIMEZONE_CHOICES
|
||||
from spirit.apps.core.utils.decorators import moderator_required, administrator_required
|
||||
import spirit.apps.core.utils
|
||||
from spirit.apps.user.utils.tokens import UserActivationTokenGenerator, UserEmailChangeTokenGenerator
|
||||
from spirit.apps.user.utils.email import send_activation_email, send_email_change_email, sender
|
||||
from spirit.apps.user.utils import email
|
||||
from spirit.apps.core.tags import time as ttags_utils
|
||||
from spirit.apps.core.tests import utils as test_utils
|
||||
from spirit.apps.core.tags.messages import render_messages
|
||||
from spirit.apps.core.utils.markdown import Markdown, quotify
|
||||
from spirit.category.models import Category
|
||||
import spirit.core.utils
|
||||
from spirit.core.utils.forms import NestedModelChoiceField
|
||||
from spirit.core.utils.timezone import TIMEZONE_CHOICES
|
||||
from spirit.core.utils.decorators import moderator_required, administrator_required
|
||||
import spirit.core.utils
|
||||
from spirit.user.utils.tokens import UserActivationTokenGenerator, UserEmailChangeTokenGenerator
|
||||
from spirit.user.utils.email import send_activation_email, send_email_change_email, sender
|
||||
from spirit.user.utils import email
|
||||
from spirit.core.tags import time as ttags_utils
|
||||
from spirit.core.tests import utils as test_utils
|
||||
from spirit.core.tags.messages import render_messages
|
||||
from spirit.core.utils.markdown import Markdown, quotify
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
@ -55,7 +55,7 @@ class UtilsTests(TestCase):
|
||||
hidden_fields = [{'errors': "error2", }, ]
|
||||
visible_fields = [{'errors': "error3", }, ]
|
||||
|
||||
res = spirit.apps.core.utils.render_form_errors(MockForm())
|
||||
res = spirit.core.utils.render_form_errors(MockForm())
|
||||
lines = [line.strip() for line in res.splitlines()]
|
||||
self.assertEqual("".join(lines), '<ul class="errorlist"><li>error1</li><li>error2</li><li>error3</li></ul>')
|
||||
|
||||
@ -63,16 +63,16 @@ class UtilsTests(TestCase):
|
||||
"""
|
||||
return json_response
|
||||
"""
|
||||
res = spirit.apps.core.utils.json_response()
|
||||
res = spirit.core.utils.json_response()
|
||||
self.assertIsInstance(res, HttpResponse)
|
||||
self.assertEqual(res.status_code, 200)
|
||||
self.assertEqual(res['Content-Type'], 'application/json')
|
||||
self.assertDictEqual(json.loads(res.content.decode('utf-8')), {})
|
||||
|
||||
res = spirit.apps.core.utils.json_response({"foo": "bar", })
|
||||
res = spirit.core.utils.json_response({"foo": "bar", })
|
||||
self.assertDictEqual(json.loads(res.content.decode('utf-8')), {"foo": "bar", })
|
||||
|
||||
res = spirit.apps.core.utils.json_response(status=404)
|
||||
res = spirit.core.utils.json_response(status=404)
|
||||
self.assertEqual(res.status_code, 404)
|
||||
|
||||
def test_mkdir_p(self):
|
||||
@ -80,11 +80,11 @@ class UtilsTests(TestCase):
|
||||
mkdir -p
|
||||
"""
|
||||
# Empty path should raise an exception
|
||||
self.assertRaises(OSError, spirit.apps.core.utils.mkdir_p, "")
|
||||
self.assertRaises(OSError, spirit.core.utils.mkdir_p, "")
|
||||
|
||||
# Try to create an existing dir should do nothing
|
||||
self.assertTrue(os.path.isdir(settings.BASE_DIR))
|
||||
spirit.apps.core.utils.mkdir_p(settings.BASE_DIR)
|
||||
spirit.core.utils.mkdir_p(settings.BASE_DIR)
|
||||
|
||||
# Create path tree
|
||||
# setup
|
||||
@ -93,7 +93,7 @@ class UtilsTests(TestCase):
|
||||
self.assertFalse(os.path.isdir(sub_path))
|
||||
self.assertFalse(os.path.isdir(path))
|
||||
# test
|
||||
spirit.apps.core.utils.mkdir_p(sub_path)
|
||||
spirit.core.utils.mkdir_p(sub_path)
|
||||
self.assertTrue(os.path.isdir(sub_path))
|
||||
# clean up
|
||||
os.rmdir(sub_path)
|
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from spirit.apps.core.tests.models import AutoSlugPopulateFromModel, AutoSlugModel, AutoSlugDefaultModel, \
|
||||
from spirit.core.tests.models import AutoSlugPopulateFromModel, AutoSlugModel, AutoSlugDefaultModel, \
|
||||
AutoSlugBadPopulateFromModel
|
||||
|
||||
|
@ -9,13 +9,13 @@ from django.test.utils import override_settings
|
||||
from django.http import Http404
|
||||
from django.core.paginator import Page, Paginator
|
||||
|
||||
from spirit.apps.core.tests import utils
|
||||
from spirit.apps.comment.models import Comment
|
||||
import spirit.apps.core.utils.paginator
|
||||
from spirit.apps.core.utils.paginator import YTPaginator, InvalidPage, YTPage
|
||||
from spirit.apps.core.utils.paginator import infinite_paginator, paginate, yt_paginate
|
||||
from spirit.apps.core.tags.paginator import render_paginator
|
||||
from spirit.apps.core.tags import paginator as ttag_paginator
|
||||
from spirit.core.tests import utils
|
||||
from spirit.comment.models import Comment
|
||||
import spirit.core.utils.paginator
|
||||
from spirit.core.utils.paginator import YTPaginator, InvalidPage, YTPage
|
||||
from spirit.core.utils.paginator import infinite_paginator, paginate, yt_paginate
|
||||
from spirit.core.tags.paginator import render_paginator
|
||||
from spirit.core.tags import paginator as ttag_paginator
|
||||
|
||||
|
||||
class UtilsPaginatorTest(TestCase):
|
||||
@ -26,13 +26,13 @@ class UtilsPaginatorTest(TestCase):
|
||||
def test_paginator_page(self):
|
||||
per_page = 15
|
||||
obj_number = 1
|
||||
self.assertEqual(spirit.apps.core.utils.paginator.get_page_number(obj_number=obj_number, per_page=per_page), 1)
|
||||
self.assertEqual(spirit.core.utils.paginator.get_page_number(obj_number=obj_number, per_page=per_page), 1)
|
||||
obj_number = per_page
|
||||
self.assertEqual(spirit.apps.core.utils.paginator.get_page_number(obj_number=obj_number, per_page=per_page), 1)
|
||||
self.assertEqual(spirit.core.utils.paginator.get_page_number(obj_number=obj_number, per_page=per_page), 1)
|
||||
obj_number = per_page - 1
|
||||
self.assertEqual(spirit.apps.core.utils.paginator.get_page_number(obj_number=obj_number, per_page=per_page), 1)
|
||||
self.assertEqual(spirit.core.utils.paginator.get_page_number(obj_number=obj_number, per_page=per_page), 1)
|
||||
obj_number = per_page + 1
|
||||
self.assertEqual(spirit.apps.core.utils.paginator.get_page_number(obj_number=obj_number, per_page=per_page), 2)
|
||||
self.assertEqual(spirit.core.utils.paginator.get_page_number(obj_number=obj_number, per_page=per_page), 2)
|
||||
|
||||
def test_paginator_url(self):
|
||||
per_page = 15
|
||||
@ -40,13 +40,13 @@ class UtilsPaginatorTest(TestCase):
|
||||
page_var = "page"
|
||||
url = "/path/"
|
||||
first_page = url + '#c' + str(obj_number)
|
||||
self.assertEqual(spirit.apps.core.utils.paginator.get_url(url, obj_number, per_page, page_var), first_page)
|
||||
self.assertEqual(spirit.core.utils.paginator.get_url(url, obj_number, per_page, page_var), first_page)
|
||||
obj_number = 16
|
||||
expected = '%(url)s?%(page_var)s=%(page_num)s#c%(obj_number)s' % {'url': url,
|
||||
'page_var': page_var,
|
||||
'page_num': 2,
|
||||
'obj_number': obj_number}
|
||||
self.assertEqual(spirit.apps.core.utils.paginator.get_url(url, obj_number, per_page, page_var), expected)
|
||||
self.assertEqual(spirit.core.utils.paginator.get_url(url, obj_number, per_page, page_var), expected)
|
||||
|
||||
|
||||
class UtilsInfinitePaginatorTest(TestCase):
|
@ -11,8 +11,8 @@ from django.contrib.messages.storage.fallback import FallbackStorage
|
||||
from django.conf import settings
|
||||
from django.core.cache import get_cache
|
||||
|
||||
from spirit.apps.core.utils.ratelimit import RateLimit
|
||||
from spirit.apps.core.utils.ratelimit.decorators import ratelimit
|
||||
from spirit.core.utils.ratelimit import RateLimit
|
||||
from spirit.core.utils.ratelimit.decorators import ratelimit
|
||||
|
||||
|
||||
def setup_request_factory_messages(req):
|
@ -5,10 +5,10 @@ from __future__ import unicode_literals
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.conf import settings
|
||||
|
||||
from spirit.apps.topic.models import Topic
|
||||
from spirit.apps.category.models import Category
|
||||
from spirit.apps.comment.models import Comment
|
||||
from spirit.apps.topic.private.models import TopicPrivate
|
||||
from spirit.topic.models import Topic
|
||||
from spirit.category.models import Category
|
||||
from spirit.comment.models import Comment
|
||||
from spirit.topic.private.models import TopicPrivate
|
||||
|
||||
|
||||
User = get_user_model()
|
@ -11,7 +11,7 @@ from django.contrib.auth import get_user_model
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
import mistune
|
||||
|
||||
from spirit.apps.core.utils.markdown.utils.emoji import emojis
|
||||
from spirit.core.utils.markdown.utils.emoji import emojis
|
||||
|
||||
User = get_user_model()
|
||||
|
@ -4,9 +4,9 @@ from __future__ import unicode_literals
|
||||
|
||||
import mistune
|
||||
|
||||
from spirit.apps.core.utils.markdown.block import BlockLexer
|
||||
from spirit.apps.core.utils.markdown.inline import InlineLexer
|
||||
from spirit.apps.core.utils.markdown.renderer import Renderer
|
||||
from spirit.core.utils.markdown.block import BlockLexer
|
||||
from spirit.core.utils.markdown.inline import InlineLexer
|
||||
from spirit.core.utils.markdown.renderer import Renderer
|
||||
|
||||
|
||||
class Markdown(mistune.Markdown):
|
5
spirit/core/utils/ratelimit/__init__.py
Normal file
5
spirit/core/utils/ratelimit/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from spirit.core.utils.ratelimit.ratelimit import RateLimit
|
||||
|
||||
__all__ = ['RateLimit']
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user