Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix render_to_string() kwarg #32

Merged
merged 2 commits into from
Jan 26, 2018
Merged
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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ Django \ Python | 2.7 | 3.4 | 3.5 | 3.6

## Documentation

The `pinax-invitations` documentation is currently under construction. If you would like to help us write documentation, please join our Slack team and let us know!

### Installation

To install pinax-invitations:
Expand Down Expand Up @@ -326,6 +324,11 @@ Fragment displays how many invites a particular user has.

## Change Log

### 6.1.2

* Replace deprecated `context_instance=RequestContext(r)` kwarg with `request=r`
* Add InviteView smoke tests

### 6.1.1

* Add django>=1.11 to requirements
Expand Down
47 changes: 46 additions & 1 deletion pinax/invitations/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django.contrib.auth.models import User
from django.core.management import call_command
from django.test import TestCase

from account.models import SignupCode
from pinax.invitations.forms import InviteForm
from pinax.invitations.models import InvitationStat, JoinInvitation
from test_plus.test import TestCase


class TestsJoinInvitation(TestCase):
Expand Down Expand Up @@ -51,3 +52,47 @@ def test_add_invites(self):
call_command("add_invites", "10")
istat = InvitationStat.objects.get(user=user)
self.assertEqual(istat.invites_remaining(), 20)


class FormTests(TestCase):

def test_already_invited(self):
"""Ensure form is not valid if invite has already been sent"""
from_user = User.objects.create(username="eldarion")
to_user = User.objects.create(username="invitee", email="[email protected]")
InvitationStat.add_invites(2)
istat = from_user.invitationstat
istat.refresh_from_db()

# Create an existing invitation
JoinInvitation.invite(from_user, to_user.email, send=False)

# Attempt to invite same user again
form_data = {
"email_address": to_user.email
}
form = InviteForm(user=from_user, data=form_data)
self.assertFalse(form.is_valid())


class ViewTests(TestCase):

def test_invite_view(self):
"""verify no errors when posting good form data"""
user = self.make_user("amy")
InvitationStat.add_invites(2)
post_data = {
"email_address": "[email protected]"
}
with self.login(user):
self.post("pinax_invitations:invite", data=post_data)
self.response_200()

def test_invite_view_bad_data(self):
"""verify no errors when posting bad data"""
user = self.make_user("sandee")
post_data = {
}
with self.login(user):
self.post("pinax_invitations:invite", data=post_data)
self.response_200()
1 change: 1 addition & 0 deletions pinax/invitations/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.conf.urls import include, url

urlpatterns = [
url(r"^account", include("account.urls")),
url(r"^", include("pinax.invitations.urls", namespace="pinax_invitations")),
]
6 changes: 3 additions & 3 deletions pinax/invitations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ def get_data(self, form):
self.invite_form_fragment, {
"form": form,
"user": self.request.user
}, context_instance=RequestContext(self.request)
}, request=self.request
),
"fragments": {
self.invites_remaining_fragment_selector: render_to_string(
self.invites_remaining_fragment, {
"invites_remaining": self.request.user.invitationstat.invites_remaining()
}, context_instance=RequestContext(self.request)
}, request=self.request
),
self.invited_fragment_selector: render_to_string(
self.invited_fragment, {
"invited_list": self.request.user.invites_sent.all()
}, context_instance=RequestContext(self.request)
}, request=self.request
)
}
}
Expand Down
22 changes: 20 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@

from django.conf import settings


DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"account",
"bootstrapform",
"pinax.invitations",
"pinax.invitations.tests"
"pinax.invitations.tests",
"pinax.templates",
],
MIDDLEWARE=[
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
],
DATABASES={
"default": {
Expand All @@ -25,6 +31,18 @@
SITE_ID=1,
ROOT_URLCONF="pinax.invitations.tests.urls",
SECRET_KEY="notasecret",
TEMPLATES=[
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
"OPTIONS": {
"debug": True,
"context_processors": [
"django.contrib.auth.context_processors.auth",
]
}
},
],
)


Expand Down
20 changes: 11 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "6.1.1"
VERSION = "6.1.2"
LONG_DESCRIPTION = """
.. image:: http://pinaxproject.com/pinax-design/patches/pinax-invitations.svg
:target: https://pypi.python.org/pypi/pinax-invitations/
Expand Down Expand Up @@ -61,14 +61,6 @@
package_data={
"invitations": []
},
install_requires=[
"django>=1.11",
"django-appconf>=1.0.1",
"django-user-accounts>=2.0.3",
],
test_suite="runtests.runtests",
tests_require=[
],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
Expand All @@ -87,5 +79,15 @@
'Programming Language :: Python :: 3.6',
"Topic :: Software Development :: Libraries :: Python Modules",
],
install_requires=[
"django>=1.11",
"django-appconf>=1.0.1",
"django-user-accounts>=2.0.3",
],
test_suite="runtests.runtests",
tests_require=[
"django-test-plus",
"pinax-templates>=1.0.2",
],
zip_safe=False,
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inline-quotes = double
[isort]
multi_line_output=3
known_django=django
known_third_party=account,appconf,pinax
known_third_party=account,appconf,pinax,test_plus
sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
include_trailing_comma=True
skip_glob=**/*/migrations/*
Expand Down