Skip to content

Commit

Permalink
Merge pull request #63 from nitely/v0.4.x
Browse files Browse the repository at this point in the history
v0.4.1
  • Loading branch information
nitely committed Aug 1, 2015
2 parents 7ad6a0d + 4cfebbf commit 2adff72
Show file tree
Hide file tree
Showing 17 changed files with 265 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ docs/_build/
*~
*.swp
*.swo

# Tx
.transifexrc
129 changes: 129 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
[main]
host = https://www.transifex.com
lang_map = sr@latin:sr_Latn, zh_CN:zh_Hans, zh_TW:zh_Hant

[spirit.core]
file_filter = spirit/core/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/core/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.admin]
file_filter = spirit/admin/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/admin/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.search]
file_filter = spirit/search/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/search/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.user]
file_filter = spirit/user/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/user/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.user_admin]
file_filter = spirit/user/admin/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/user/admin/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.user_auth]
file_filter = spirit/user/auth/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/user/auth/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.category]
file_filter = spirit/category/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/category/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.category_admin]
file_filter = spirit/category/admin/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/category/admin/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.topic]
file_filter = spirit/topic/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/topic/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.topic_admin]
file_filter = spirit/topic/admin/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/topic/admin/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.topic_favorite]
file_filter = spirit/topic/favorite/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/topic/favorite/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.topic_notification]
file_filter = spirit/topic/notification/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/topic/notification/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.topic_poll]
file_filter = spirit/topic/poll/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/topic/poll/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.topic_private]
file_filter = spirit/topic/private/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/topic/private/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.topic_unread]
file_filter = spirit/topic/unread/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/topic/unread/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.comment]
file_filter = spirit/comment/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/comment/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.comment_bookmark]
file_filter = spirit/comment/bookmark/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/comment/bookmark/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.comment_flag]
file_filter = spirit/comment/flag/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/comment/flag/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.comment_flag_admin]
file_filter = spirit/comment/flag/admin/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/comment/flag/admin/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.comment_history]
file_filter = spirit/comment/history/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/comment/history/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[spirit.comment_like]
file_filter = spirit/comment/like/locale/<lang>/LC_MESSAGES/django.po
source_file = spirit/comment/like/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.4.1
==================

* Adds missing user profile migration (issue #62)

0.4.0
==================

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='django-spirit',
version='0.4.0',
version='0.4.1',
description='Spirit is a Python based forum powered by Django.',
author='Esteban Castro Borsani',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion spirit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from __future__ import unicode_literals

__version__ = '0.4.0'
__version__ = '0.4.1'
Empty file.
Empty file.
34 changes: 34 additions & 0 deletions spirit/core/management/commands/spiritcompilemessages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
import os

from django.core.management.base import BaseCommand, CommandError
from django.core.management import call_command
from django.conf import settings


class Command(BaseCommand):
help = 'Compiles .po files created by makemessages to .mo ' \
'files for use with the builtin gettext support'

requires_system_checks = False

def handle(self, *args, **options):
if not settings.ST_BASE_DIR.endswith('spirit'):
raise CommandError(
'settings.ST_BASE_DIR is not the spirit root folder, are you overriding it?'
)

base_dir = os.getcwd()

for root, dirs, files in os.walk(settings.ST_BASE_DIR):
if 'locale' not in dirs:
continue

os.chdir(root)
call_command('compilemessages', stdout=self.stdout, stderr=self.stderr)
os.chdir(base_dir)

self.stdout.write('ok')
self.stdout.write('Run \'python manage.py spirittxpush\' to push the changes to transifex.')
27 changes: 27 additions & 0 deletions spirit/core/management/commands/spirittxpush.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
from subprocess import call
import os

from django.core.management.base import BaseCommand, CommandError
from django.conf import settings


class Command(BaseCommand):
help = 'Pushes all the local files listed in ./.tx/config to transifex'

requires_system_checks = False

def handle(self, *args, **options):
# todo: test or not to test?
# Requir python27 and "pip install transifex-client==0.11b3"
root = os.path.split(settings.ST_BASE_DIR)[0]
tx_dir = os.path.join(root, '.tx')

if not os.path.isdir(tx_dir):
raise CommandError('Can\'t find the .tx folder in %s' % (root, ))

os.chdir(root)
call(["tx", "push", "-s", "-t", "--skip"])
self.stdout.write('ok')
2 changes: 1 addition & 1 deletion spirit/core/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def process_request(self, request):

full_namespace = ':'.join(resolver_match.namespaces)

if full_namespace != 'spirit:user:auth':
if full_namespace == 'spirit:user:auth':
return

return redirect_to_login(
Expand Down
23 changes: 23 additions & 0 deletions spirit/core/tests/tests_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from django.test import TestCase
from django.core.management import call_command
from django.utils.six import StringIO


class CommandsTests(TestCase):

def test_command_spiritcompilemessages(self):
"""
Should compile all locales under the spirit root folder
"""
out = StringIO()
err = StringIO()
call_command('spiritcompilemessages', stdout=out, stderr=err)
out_put = out.getvalue().strip().splitlines()
out_put_err = err.getvalue().strip().splitlines()
self.assertTrue(out_put[0].startswith("processing file django.po in"))
self.assertEqual(out_put[-2], "ok")
self.assertEqual(out_put_err, [])
17 changes: 7 additions & 10 deletions spirit/core/utils/paginator/infinite_paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@
from __future__ import unicode_literals

from django.http import Http404
from django.shortcuts import get_object_or_404

from infinite_scroll_pagination.paginator import SeekPaginator, EmptyPage


def paginate(request, query_set, lookup_field, per_page=15, page_var='value'):
# TODO: remove
value = None
page_pk = request.GET.get(page_var, None)
paginator = SeekPaginator(query_set, per_page=per_page, lookup_field=lookup_field)

# First page
if page_pk is None:
return paginator.page()
# It's not the first page
if page_pk is not None:
obj = get_object_or_404(query_set.model, pk=page_pk)
value = getattr(obj, lookup_field)

try:
obj = query_set.model.objects.get(pk=page_pk)
except query_set.model.DoesNotExist:
raise Http404()

value = getattr(obj, lookup_field)
paginator = SeekPaginator(query_set, per_page=per_page, lookup_field=lookup_field)

try:
page = paginator.page(value=value, pk=page_pk)
Expand Down
2 changes: 1 addition & 1 deletion spirit/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from spirit.user.middleware import TimezoneMiddleware, LastIPMiddleware,\
LastSeenMiddleware, ActiveUserMiddleware

# TODO: remove in Spirit 0.4
# TODO: remove in Spirit 0.5


__all__ = [
Expand Down
2 changes: 2 additions & 0 deletions spirit/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

ST_UNIQUE_EMAILS = True

ST_BASE_DIR = os.path.dirname(__file__)

#
# Django & Spirit settings defined below...
#
Expand Down
Binary file modified spirit/topic/poll/locale/es/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion spirit/user/admin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class UserProfileForm(forms.ModelForm):

class Meta:
model = UserProfile
fields = ("location", "timezone", "is_administrator", "is_moderator")
fields = ("location", "timezone", "is_verified", "is_administrator", "is_moderator")
30 changes: 30 additions & 0 deletions spirit/user/migrations/0004_auto_20150731_2351.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.conf import settings


def migrate_profiles(apps, schema_editor):
User = apps.get_model(settings.AUTH_USER_MODEL)
UserProfile = apps.get_model('spirit_user', 'UserProfile')

users = User.objects.filter(st=None)

# Avoid using bulk_create coz there are things setted on save
for user in users:
st = UserProfile()
st.user = user
st.is_verified = True
st.save()


class Migration(migrations.Migration):

dependencies = [
('spirit_user', '0003_auto_20150728_0448'),
]

operations = [
migrations.RunPython(migrate_profiles),
]

0 comments on commit 2adff72

Please sign in to comment.