Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ env/
.coverage
htmlcov/
pybb_upload/

# this one gets created when opening in github codespace
build/
4 changes: 2 additions & 2 deletions pybb/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Meta(object):
def __init__(self, *args, **kwargs):
# Move args to kwargs
if args:
kwargs.update(dict(zip(inspect.getargspec(super(PostForm, self).__init__)[0][1:], args)))
kwargs.update(dict(zip(inspect.getfullargspec(super(PostForm, self).__init__)[0][1:], args)))
self.user = kwargs.pop('user', None)
self.ip = kwargs.pop('ip', None)
self.topic = kwargs.pop('topic', None)
Expand Down Expand Up @@ -300,7 +300,7 @@ class AdminPostForm(PostForm):

def __init__(self, *args, **kwargs):
if args:
kwargs.update(dict(zip(inspect.getargspec(forms.ModelForm.__init__)[0][1:], args)))
kwargs.update(dict(zip(inspect.getfullargspec(forms.ModelForm.__init__)[0][1:], args)))
if 'instance' in kwargs and kwargs['instance']:
kwargs.setdefault('initial', {}).update({'login': getattr(kwargs['instance'].user, username_field)})
super(AdminPostForm, self).__init__(**kwargs)
Expand Down
6 changes: 3 additions & 3 deletions pybb/templatetags/pybb_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ def newfunc(user):
continue # pragma: no cover - only methods are used to dynamically build templatetags
if not method_name.startswith('may') and not method_name.startswith('filter'):
continue # pragma: no cover - only (may|filter)* methods are used to dynamically build templatetags
method_args = inspect.getargspec(method).args
method_args = inspect.getfullargspec(method).args
args_count = len(method_args)
if args_count not in (2, 3):
continue # pragma: no cover - only methods with 2 or 3 params
if method_args[0] != 'self' or method_args[1] != 'user':
continue # pragma: no cover - only methods with self and user as first args
if len(inspect.getargspec(method).args) == 3:
if len(inspect.getfullargspec(method).args) == 3:
register.filter('%s%s' % ('pybb_', method_name), partial(method_name, perms))
elif len(inspect.getargspec(method).args) == 2:
elif len(inspect.getfullargspec(method).args) == 2:
register.filter('%s%s' % ('pybb_', method_name), partial_no_param(method_name, perms))
load_perms_filters()

Expand Down
26 changes: 13 additions & 13 deletions pybb/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3291,43 +3291,43 @@ def test_redirect_category(self):
self.assertRedirects(r, settings.LOGIN_URL + '?next=%s' % self.category.get_absolute_url())
# access with (unauthorized) user should get 403 (forbidden)
r = self.get_with_user(self.category.get_absolute_url(), 'nostaff', 'nostaff')
self.assertEquals(r.status_code, 403)
self.assertEqual(r.status_code, 403)
# allowed user is allowed
r = self.get_with_user(self.category.get_absolute_url(), 'staff', 'staff')
self.assertEquals(r.status_code, 200)
self.assertEqual(r.status_code, 200)

def test_redirect_forum(self):
# access without user should be redirected
r = self.get_with_user(self.forum.get_absolute_url())
self.assertRedirects(r, settings.LOGIN_URL + '?next=%s' % self.forum.get_absolute_url())
# access with (unauthorized) user should get 403 (forbidden)
r = self.get_with_user(self.forum.get_absolute_url(), 'nostaff', 'nostaff')
self.assertEquals(r.status_code, 403)
self.assertEqual(r.status_code, 403)
# allowed user is allowed
r = self.get_with_user(self.forum.get_absolute_url(), 'staff', 'staff')
self.assertEquals(r.status_code, 200)
self.assertEqual(r.status_code, 200)

def test_redirect_topic(self):
# access without user should be redirected
r = self.get_with_user(self.topic.get_absolute_url())
self.assertRedirects(r, settings.LOGIN_URL + '?next=%s' % self.topic.get_absolute_url())
# access with (unauthorized) user should get 403 (forbidden)
r = self.get_with_user(self.topic.get_absolute_url(), 'nostaff', 'nostaff')
self.assertEquals(r.status_code, 403)
self.assertEqual(r.status_code, 403)
# allowed user is allowed
r = self.get_with_user(self.topic.get_absolute_url(), 'staff', 'staff')
self.assertEquals(r.status_code, 200)
self.assertEqual(r.status_code, 200)

def test_redirect_post(self):
# access without user should be redirected
r = self.get_with_user(self.post.get_absolute_url())
self.assertRedirects(r, settings.LOGIN_URL + '?next=%s' % self.post.get_absolute_url())
# access with (unauthorized) user should get 403 (forbidden)
r = self.get_with_user(self.post.get_absolute_url(), 'nostaff', 'nostaff')
self.assertEquals(r.status_code, 403)
self.assertEqual(r.status_code, 403)
# allowed user is allowed
r = self.get_with_user(self.post.get_absolute_url(), 'staff', 'staff')
self.assertEquals(r.status_code, 302)
self.assertEqual(r.status_code, 302)

@override_settings(PYBB_ENABLE_ANONYMOUS_POST=False)
def test_redirect_topic_add(self):
Expand All @@ -3340,13 +3340,13 @@ def test_redirect_topic_add(self):

# access with (unauthorized) user should get 403 (forbidden)
r = self.get_with_user(add_topic_url, 'staff', 'staff')
self.assertEquals(r.status_code, 403)
self.assertEqual(r.status_code, 403)

_detach_perms_class()

# allowed user is allowed
r = self.get_with_user(add_topic_url, 'staff', 'staff')
self.assertEquals(r.status_code, 200)
self.assertEqual(r.status_code, 200)

def test_redirect_post_edit(self):
_attach_perms_class('pybb.tests.RestrictEditingHandler')
Expand All @@ -3358,13 +3358,13 @@ def test_redirect_post_edit(self):

# access with (unauthorized) user should get 403 (forbidden)
r = self.get_with_user(edit_post_url, 'staff', 'staff')
self.assertEquals(r.status_code, 403)
self.assertEqual(r.status_code, 403)

_detach_perms_class()

# allowed user is allowed
r = self.get_with_user(edit_post_url, 'staff', 'staff')
self.assertEquals(r.status_code, 200)
self.assertEqual(r.status_code, 200)

def test_profile_autocreation_signal_on(self):
user = User.objects.create_user('cronos', 'cronos@localhost', 'cronos')
Expand Down Expand Up @@ -4028,7 +4028,7 @@ def test(self):
continue # only methods are used to dynamically build templatetags
if not method_name.startswith('may') and not method_name.startswith('filter'):
continue # only (may|filter)* methods are used to dynamically build templatetags
method_args = inspect.getargspec(method).args
method_args = inspect.getfullargspec(method).args
args_count = len(method_args)
if args_count not in (2, 3):
continue # only methods with 2 or 3 params
Expand Down
54 changes: 27 additions & 27 deletions pybb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

urlpatterns += [
# Index, Category, Forum
re_path('^$', IndexView.as_view(), name='index'),
re_path('^category/(?P<pk>\d+)/$', CategoryView.as_view(), name='category'),
re_path('^forum/(?P<pk>\d+)/$', ForumView.as_view(), name='forum'),
re_path(r'^$', IndexView.as_view(), name='index'),
re_path(r'^category/(?P<pk>\d+)/$', CategoryView.as_view(), name='category'),
re_path(r'^forum/(?P<pk>\d+)/$', ForumView.as_view(), name='forum'),

# User
re_path('^users/(?P<username>[^/]+)/$', UserView.as_view(), name='user'),
re_path('^block_user/([^/]+)/$', block_user, name='block_user'),
re_path('^unblock_user/([^/]+)/$', unblock_user, name='unblock_user'),
re_path(r'^users/(?P<username>[^/]+)/$', UserView.as_view(), name='user'),
re_path(r'^block_user/([^/]+)/$', block_user, name='block_user'),
re_path(r'^unblock_user/([^/]+)/$', unblock_user, name='unblock_user'),
re_path(r'^users/(?P<username>[^/]+)/topics/$', UserTopics.as_view(),
name='user_topics'),
re_path(r'^users/(?P<username>[^/]+)/posts/$', UserPosts.as_view(),
Expand All @@ -38,56 +38,56 @@
UserEditPrivilegesView.as_view(), name='edit_privileges'),

# Profile
re_path('^profile/edit/$', ProfileEditView.as_view(), name='edit_profile'),
re_path(r'^profile/edit/$', ProfileEditView.as_view(), name='edit_profile'),

# Topic
re_path('^topic/(?P<pk>\d+)/$', TopicView.as_view(), name='topic'),
re_path('^topic/(?P<pk>\d+)/stick/$', StickTopicView.as_view(),
re_path(r'^topic/(?P<pk>\d+)/$', TopicView.as_view(), name='topic'),
re_path(r'^topic/(?P<pk>\d+)/stick/$', StickTopicView.as_view(),
name='stick_topic'),
re_path('^topic/(?P<pk>\d+)/unstick/$', UnstickTopicView.as_view(),
re_path(r'^topic/(?P<pk>\d+)/unstick/$', UnstickTopicView.as_view(),
name='unstick_topic'),
re_path('^topic/(?P<pk>\d+)/close/$', CloseTopicView.as_view(),
re_path(r'^topic/(?P<pk>\d+)/close/$', CloseTopicView.as_view(),
name='close_topic'),
re_path('^topic/(?P<pk>\d+)/open/$', OpenTopicView.as_view(),
re_path(r'^topic/(?P<pk>\d+)/open/$', OpenTopicView.as_view(),
name='open_topic'),
re_path('^topic/(?P<pk>\d+)/poll_vote/$', TopicPollVoteView.as_view(),
re_path(r'^topic/(?P<pk>\d+)/poll_vote/$', TopicPollVoteView.as_view(),
name='topic_poll_vote'),
re_path('^topic/(?P<pk>\d+)/cancel_poll_vote/$', topic_cancel_poll_vote,
re_path(r'^topic/(?P<pk>\d+)/cancel_poll_vote/$', topic_cancel_poll_vote,
name='topic_cancel_poll_vote'),
re_path('^topic/latest/$', LatestTopicsView.as_view(), name='topic_latest'),
re_path(r'^topic/latest/$', LatestTopicsView.as_view(), name='topic_latest'),

# Add topic/post
re_path('^forum/(?P<forum_id>\d+)/topic/add/$', AddPostView.as_view(),
re_path(r'^forum/(?P<forum_id>\d+)/topic/add/$', AddPostView.as_view(),
name='add_topic'),
re_path('^topic/(?P<topic_id>\d+)/post/add/$', AddPostView.as_view(),
re_path(r'^topic/(?P<topic_id>\d+)/post/add/$', AddPostView.as_view(),
name='add_post'),

# Post
re_path('^post/(?P<pk>\d+)/$', PostView.as_view(), name='post'),
re_path('^post/(?P<pk>\d+)/edit/$', EditPostView.as_view(), name='edit_post'),
re_path('^post/(?P<pk>\d+)/move/$', MovePostView.as_view(), name='move_post'),
re_path('^post/(?P<pk>\d+)/delete/$', DeletePostView.as_view(),
re_path(r'^post/(?P<pk>\d+)/$', PostView.as_view(), name='post'),
re_path(r'^post/(?P<pk>\d+)/edit/$', EditPostView.as_view(), name='edit_post'),
re_path(r'^post/(?P<pk>\d+)/move/$', MovePostView.as_view(), name='move_post'),
re_path(r'^post/(?P<pk>\d+)/delete/$', DeletePostView.as_view(),
name='delete_post'),
re_path('^post/(?P<pk>\d+)/moderate/$', ModeratePost.as_view(),
re_path(r'^post/(?P<pk>\d+)/moderate/$', ModeratePost.as_view(),
name='moderate_post'),

# Attachment
# url('^attachment/(\w+)/$', 'show_attachment', name='pybb_attachment'),

# Subscription
re_path('^subscription/topic/(\d+)/delete/$',
re_path(r'^subscription/topic/(\d+)/delete/$',
delete_subscription, name='delete_subscription'),
re_path('^subscription/topic/(\d+)/add/$',
re_path(r'^subscription/topic/(\d+)/add/$',
add_subscription, name='add_subscription'),
re_path('^subscription/forum/(?P<pk>\d+)/$',
re_path(r'^subscription/forum/(?P<pk>\d+)/$',
ForumSubscriptionView.as_view(), name='forum_subscription'),

# API
re_path('^api/post_ajax_preview/$', post_ajax_preview,
re_path(r'^api/post_ajax_preview/$', post_ajax_preview,
name='post_ajax_preview'),

# Commands
re_path('^mark_all_as_read/$', mark_all_as_read, name='mark_all_as_read')
re_path(r'^mark_all_as_read/$', mark_all_as_read, name='mark_all_as_read')
]

if PYBB_NICE_URL:
Expand Down
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='pybbm',
version='0.19.0',
version='0.19.1',
description='PyBB Modified. Django forum application',
long_description=open('README.rst').read(),
author='Pavel Zhukov',
Expand All @@ -27,11 +27,12 @@
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Message Boards',
'Topic :: Software Development :: Libraries :: Python Modules',
],
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{38,39,310,311}-django{42}-{sqlite,postgres,mysql},coverage
envlist = py{38,39,310,311,312,313}-django{42}-{sqlite,postgres,mysql},coverage

[testenv:coverage]
deps =
Expand Down