Skip to content

Commit 79e278e

Browse files
authored
Merge pull request #67 from shellfly/feature/votemixin
Add VoteMixin & Django 3.0 test
2 parents bde968c + 19e5fe9 commit 79e278e

File tree

17 files changed

+162
-116
lines changed

17 files changed

+162
-116
lines changed

.travis.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
language: python
22
python:
3-
- "2.7"
4-
- "3.5"
3+
- "3.7"
54
env:
6-
- DJANGO_VERSION=1.7
7-
- DJANGO_VERSION=1.8
8-
- DJANGO_VERSION=1.9
9-
- DJANGO_VERSION=1.10
105
- DJANGO_VERSION=2.0
6+
- DJANGO_VERSION=3.0
117
install:
12-
- pip install -q Django==$DJANGO_VERSION flake8 coverage
8+
- pip install -q Django==$DJANGO_VERSION flake8 coverage djangorestframework
139
script:
1410
- flake8 --exclude vote/migrations/* vote
1511
- coverage run runtests.py
16-
matrix:
17-
exclude:
18-
- python: "3.5"
19-
env: DJANGO_VERSION=1.7
20-
- python: "2.7"
21-
env: DJANGO_VERSION=2.0
2212

2313
after_success:
2414
- bash <(curl -s https://codecov.io/bash)

CHANGELOG.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,16 @@ Review.votes.all(user_id)
7171

7272
```
7373

74-
``django-vote`` now requires Django 1.7 or greater. (for Django < 1.7, please install previous release `django-vote==1.1.3`)
74+
#### Use `VoteMixin` for REST API
75+
76+
``` python
77+
class CommentViewSet(ModelViewSet, VoteMixin):
78+
queryset = Comment.objects.all()
79+
serializer_class = CommentSerializer
80+
```
81+
82+
```sh
83+
POST /api/comments/{id}/vote/
84+
POST /api/comments/{id}/vote/ {"action":"down"}
85+
DELETE /api/comments/{id}/vote/
86+
```

docs/changelog.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
=========
33

4+
2.2.0 (2020.05.20)
5+
------------------
6+
* Add post_vote signal
7+
* Add VoteMixin for easily write vote api
8+
* Drop support for Django < 2.0
9+
* Add Django 3.0 test
10+
11+
2.1.7(2018.05.08)
12+
-----------------
13+
* fix template tag error on Django 2.0
414

515
2.1.6(2017.12.20)
616
------------------

docs/conf.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
# General information about the project.
4343
project = u'django-vote'
44-
copyright = u'2014, shellfly'
44+
copyright = u'2014-2020, shellfly'
4545

4646
# The version info for the project you're documenting, acts as replacement for
4747
# |version| and |release|, also used in various other places throughout the
@@ -195,25 +195,25 @@
195195
# -- Options for LaTeX output ---------------------------------------------
196196

197197
latex_elements = {
198-
# The paper size ('letterpaper' or 'a4paper').
199-
#'papersize': 'letterpaper',
198+
# The paper size ('letterpaper' or 'a4paper').
199+
# 'papersize': 'letterpaper',
200200

201-
# The font size ('10pt', '11pt' or '12pt').
202-
#'pointsize': '10pt',
201+
# The font size ('10pt', '11pt' or '12pt').
202+
# 'pointsize': '10pt',
203203

204-
# Additional stuff for the LaTeX preamble.
205-
#'preamble': '',
204+
# Additional stuff for the LaTeX preamble.
205+
# 'preamble': '',
206206

207-
# Latex figure (float) alignment
208-
#'figure_align': 'htbp',
207+
# Latex figure (float) alignment
208+
# 'figure_align': 'htbp',
209209
}
210210

211211
# Grouping the document tree into LaTeX files. List of tuples
212212
# (source start file, target name, title,
213213
# author, documentclass [howto, manual, or own class]).
214214
latex_documents = [
215-
('index', 'django-vote.tex', u'django-vote Documentation',
216-
u'shellfly', 'manual'),
215+
('index', 'django-vote.tex', u'django-vote Documentation',
216+
u'shellfly', 'manual'),
217217
]
218218

219219
# The name of an image file (relative to this directory) to place at the top of
@@ -256,9 +256,9 @@
256256
# (source start file, target name, title, author,
257257
# dir menu entry, description, category)
258258
texinfo_documents = [
259-
('index', 'django-vote', u'django-vote Documentation',
260-
u'shellfly', 'django-vote', 'One line description of project.',
261-
'Miscellaneous'),
259+
('index', 'django-vote', u'django-vote Documentation',
260+
u'shellfly', 'django-vote', 'One line description of project.',
261+
'Miscellaneous'),
262262
]
263263

264264
# Documents to append as an appendix to all manuals.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Welcome to django-vote's documentation!
1313

1414
getting_started
1515
api
16+
rest api
1617
changelog
1718

1819

docs/rest api.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
REST API
2+
========
3+
4+
There is a `VoteMixin` for you to easily add rest api to conduct vote::
5+
6+
from vote.views import VoteMixin
7+
8+
class CommentViewSet(VoteMixin,ModelViewSet):
9+
# ... fields here

runtests.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@
1919
'test',
2020
],
2121
ROOT_URLCONF="test.urls",
22-
MIDDLEWARE_CLASSES = [
22+
MIDDLEWARE_CLASSES=[ # Deprecated in Django 1.10 https://docs.djangoproject.com/en/1.11/ref/settings/#middleware-classes
2323
'django.contrib.sessions.middleware.SessionMiddleware',
2424
'django.contrib.auth.middleware.AuthenticationMiddleware',
2525
],
26-
TEMPLATES = [
26+
MIDDLEWARE=[
27+
'django.contrib.sessions.middleware.SessionMiddleware',
28+
'django.contrib.auth.middleware.AuthenticationMiddleware',
29+
],
30+
TEMPLATES=[
2731
{
2832
'BACKEND': 'django.template.backends.django.DjangoTemplates',
2933
'APP_DIRS': True,
@@ -32,10 +36,10 @@
3236
'django.template.context_processors.request',
3337
'django.contrib.auth.context_processors.auth',
3438
],
35-
39+
3640
},
3741
},
38-
42+
3943
]
4044
)
4145

@@ -44,5 +48,6 @@ def runtests():
4448
argv = sys.argv[:1] + ['test'] + sys.argv[1:]
4549
execute_from_command_line(argv)
4650

51+
4752
if __name__ == '__main__':
4853
runtests()

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@
1818
license='BSD License',
1919
description='A simple Django app to conduct vote.',
2020
long_description=README,
21-
url='https://github.com/Beeblio/django-vote',
21+
url='https://github.com/shellfly/django-vote',
2222
author='shellfly',
2323
author_email='[email protected]',
2424
classifiers=[
25-
'Development Status :: 4 - Beta',
25+
'Development Status :: 5 - Production/Stable',
2626
'Environment :: Web Environment',
2727
'Framework :: Django',
2828
'Framework :: Django :: 1.7',
2929
'Framework :: Django :: 1.8',
3030
'Framework :: Django :: 1.9',
3131
'Framework :: Django :: 1.10',
3232
'Framework :: Django :: 2.0',
33+
'Framework :: Django :: 3.0',
3334
'Intended Audience :: Developers',
3435
'License :: OSI Approved :: BSD License',
3536
'Programming Language :: Python :: 2.7',
36-
'Programming Language :: Python :: 3.5',
37+
'Programming Language :: Python :: 3.8',
3738
],
3839
)

test/serializers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from .models import Comment
2+
from rest_framework import serializers
3+
4+
5+
class CommentSerializer(serializers.ModelSerializer):
6+
class Meta:
7+
model = Comment
8+
fields = '__all__'

0 commit comments

Comments
 (0)