├── .coveragerc ├── .editorconfig ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── AUTHORS.rst ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── README.rst ├── django_mptt_comments ├── __init__.py ├── admin.py ├── apps.py ├── forms.py ├── migrations │ ├── 0001_initial.py │ └── __init__.py ├── models.py ├── static │ ├── css │ │ └── django_mptt_comments.css │ ├── img │ │ └── .gitignore │ └── js │ │ └── django_mptt_comments.js ├── templates │ └── django_mptt_comments │ │ ├── base.html │ │ └── reply.html ├── templatetags │ ├── __init__.py │ └── mptt_comment_tags.py ├── urls.py ├── utils.py └── views.py ├── docs ├── Makefile ├── authors.rst ├── conf.py ├── contributing.rst ├── history.rst ├── index.rst ├── installation.rst ├── make.bat ├── readme.rst └── usage.rst ├── example ├── README.md ├── blog │ ├── __init__.py │ ├── admin.py │ ├── migrations │ │ ├── 0001_initial.py │ │ └── __init__.py │ ├── models.py │ ├── urls.py │ └── views.py ├── db_tools │ └── __init__.py ├── example │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── manage.py ├── requirements.txt └── templates │ ├── blog │ ├── detail.html │ └── index.html │ ├── comments │ ├── form.html │ └── list.html │ └── django_mptt_comments │ └── base.html ├── manage.py ├── requirements.txt ├── requirements_dev.txt ├── requirements_test.txt ├── runtests.py ├── setup.cfg ├── setup.py ├── tests ├── __init__.py ├── models.py ├── settings.py ├── test_forms.py ├── test_models.py ├── test_views.py └── urls.py └── tox.ini /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = true 3 | 4 | [report] 5 | omit = 6 | *site-packages* 7 | *tests* 8 | *.tox* 9 | show_missing = True 10 | exclude_lines = 11 | raise NotImplementedError 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.{py,rst,ini}] 12 | indent_style = space 13 | indent_size = 4 14 | 15 | [*.{html,css,scss,json,yml}] 16 | indent_style = space 17 | indent_size = 2 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [Makefile] 23 | indent_style = tab 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | * django-mptt-comments version: 2 | * Django version: 3 | * Python version: 4 | * Operating System: 5 | 6 | ### Description 7 | 8 | Describe what you were trying to get done. 9 | Tell us what happened, what went wrong, and what you expected to happen. 10 | 11 | ### What I Did 12 | 13 | ``` 14 | Paste the command(s) you ran and the output. 15 | If there was a crash, please include the traceback here. 16 | ``` 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | __pycache__ 3 | 4 | # C extensions 5 | *.so 6 | 7 | # Packages 8 | *.egg 9 | *.egg-info 10 | dist 11 | build 12 | eggs 13 | parts 14 | bin 15 | var 16 | sdist 17 | develop-eggs 18 | .installed.cfg 19 | lib 20 | lib64 21 | 22 | # Installer logs 23 | pip-log.txt 24 | 25 | # Unit test / coverage reports 26 | .coverage 27 | .tox 28 | nosetests.xml 29 | htmlcov 30 | 31 | # Translations 32 | *.mo 33 | 34 | # Mr Developer 35 | .mr.developer.cfg 36 | .project 37 | .pydevproject 38 | 39 | # Pycharm/Intellij 40 | .idea 41 | 42 | # Complexity 43 | output/*.html 44 | output/*/index.html 45 | 46 | # Sphinx 47 | docs/_build 48 | 49 | # Virtualenv 50 | .venv 51 | 52 | # Local 53 | *.sqlite3 54 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Config file for automatic testing at travis-ci.org 2 | 3 | language: python 4 | 5 | python: 6 | - "3.6" 7 | 8 | env: 9 | - TOX_ENV=py36-django-111 10 | - TOX_ENV=py35-django-111 11 | - TOX_ENV=py34-django-111 12 | - TOX_ENV=py27-django-111 13 | - TOX_ENV=py36-django-20 14 | - TOX_ENV=py35-django-20 15 | - TOX_ENV=py34-django-20 16 | 17 | matrix: 18 | fast_finish: true 19 | 20 | # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors 21 | install: pip install -r requirements_test.txt 22 | 23 | # command to run tests using coverage, e.g. python setup.py test 24 | script: tox -e $TOX_ENV 25 | 26 | after_success: 27 | - codecov -e TOX_ENV 28 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Xueguang Yang 9 | 10 | Contributors 11 | ------------ 12 | 13 | None yet. Why not be the first? 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Contributing 3 | ============ 4 | 5 | Contributions are welcome, and they are greatly appreciated! Every 6 | little bit helps, and credit will always be given. 7 | 8 | You can contribute in many ways: 9 | 10 | Types of Contributions 11 | ---------------------- 12 | 13 | Report Bugs 14 | ~~~~~~~~~~~ 15 | 16 | Report bugs at https://github.com/zmrenwu/django-mptt-comments/issues. 17 | 18 | If you are reporting a bug, please include: 19 | 20 | * Your operating system name and version. 21 | * Any details about your local setup that might be helpful in troubleshooting. 22 | * Detailed steps to reproduce the bug. 23 | 24 | Fix Bugs 25 | ~~~~~~~~ 26 | 27 | Look through the GitHub issues for bugs. Anything tagged with "bug" 28 | is open to whoever wants to implement it. 29 | 30 | Implement Features 31 | ~~~~~~~~~~~~~~~~~~ 32 | 33 | Look through the GitHub issues for features. Anything tagged with "feature" 34 | is open to whoever wants to implement it. 35 | 36 | Write Documentation 37 | ~~~~~~~~~~~~~~~~~~~ 38 | 39 | django-mptt-comments could always use more documentation, whether as part of the 40 | official django-mptt-comments docs, in docstrings, or even on the web in blog posts, 41 | articles, and such. 42 | 43 | Submit Feedback 44 | ~~~~~~~~~~~~~~~ 45 | 46 | The best way to send feedback is to file an issue at https://github.com/zmrenwu/django-mptt-comments/issues. 47 | 48 | If you are proposing a feature: 49 | 50 | * Explain in detail how it would work. 51 | * Keep the scope as narrow as possible, to make it easier to implement. 52 | * Remember that this is a volunteer-driven project, and that contributions 53 | are welcome :) 54 | 55 | Get Started! 56 | ------------ 57 | 58 | Ready to contribute? Here's how to set up `django-mptt-comments` for local development. 59 | 60 | 1. Fork the `django-mptt-comments` repo on GitHub. 61 | 2. Clone your fork locally:: 62 | 63 | $ git clone git@github.com:your_name_here/django-mptt-comments.git 64 | 65 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 66 | 67 | $ mkvirtualenv django-mptt-comments 68 | $ cd django-mptt-comments/ 69 | $ python setup.py develop 70 | 71 | 4. Create a branch for local development:: 72 | 73 | $ git checkout -b name-of-your-bugfix-or-feature 74 | 75 | Now you can make your changes locally. 76 | 77 | 5. When you're done making changes, check that your changes pass flake8 and the 78 | tests, including testing other Python versions with tox:: 79 | 80 | $ flake8 django_mptt_comments tests 81 | $ python setup.py test 82 | $ tox 83 | 84 | To get flake8 and tox, just pip install them into your virtualenv. 85 | 86 | 6. Commit your changes and push your branch to GitHub:: 87 | 88 | $ git add . 89 | $ git commit -m "Your detailed description of your changes." 90 | $ git push origin name-of-your-bugfix-or-feature 91 | 92 | 7. Submit a pull request through the GitHub website. 93 | 94 | Pull Request Guidelines 95 | ----------------------- 96 | 97 | Before you submit a pull request, check that it meets these guidelines: 98 | 99 | 1. The pull request should include tests. 100 | 2. If the pull request adds functionality, the docs should be updated. Put 101 | your new functionality into a function with a docstring, and add the 102 | feature to the list in README.rst. 103 | 3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check 104 | https://travis-ci.org/zmrenwu/django-mptt-comments/pull_requests 105 | and make sure that the tests pass for all supported Python versions. 106 | 107 | Tips 108 | ---- 109 | 110 | To run a subset of tests:: 111 | 112 | $ python -m unittest tests.test_django_mptt_comments 113 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | .. :changelog: 2 | 3 | History 4 | ------- 5 | 6 | 0.1.0 (2018-07-14) 7 | ++++++++++++++++++ 8 | 9 | * First release on PyPI. 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Copyright (c) 2018, Xueguang Yang 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | recursive-include django_mptt_comments *.html *.png *.gif *js *.css *jpg *jpeg *svg *py 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean-pyc clean-build docs help 2 | .DEFAULT_GOAL := help 3 | define BROWSER_PYSCRIPT 4 | import os, webbrowser, sys 5 | try: 6 | from urllib import pathname2url 7 | except: 8 | from urllib.request import pathname2url 9 | 10 | webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) 11 | endef 12 | export BROWSER_PYSCRIPT 13 | BROWSER := python -c "$$BROWSER_PYSCRIPT" 14 | 15 | help: 16 | @grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' 17 | 18 | clean: clean-build clean-pyc 19 | 20 | clean-build: ## remove build artifacts 21 | rm -fr build/ 22 | rm -fr dist/ 23 | rm -fr *.egg-info 24 | 25 | clean-pyc: ## remove Python file artifacts 26 | find . -name '*.pyc' -exec rm -f {} + 27 | find . -name '*.pyo' -exec rm -f {} + 28 | find . -name '*~' -exec rm -f {} + 29 | 30 | lint: ## check style with flake8 31 | flake8 django_mptt_comments tests 32 | 33 | test: ## run tests quickly with the default Python 34 | python runtests.py tests 35 | 36 | test-all: ## run tests on every Python version with tox 37 | tox 38 | 39 | coverage: ## check code coverage quickly with the default Python 40 | coverage run --source django_mptt_comments runtests.py tests 41 | coverage report -m 42 | coverage html 43 | open htmlcov/index.html 44 | 45 | docs: ## generate Sphinx HTML documentation, including API docs 46 | rm -f docs/django-mptt-comments.rst 47 | rm -f docs/modules.rst 48 | sphinx-apidoc -o docs/ django_mptt_comments 49 | $(MAKE) -C docs clean 50 | $(MAKE) -C docs html 51 | $(BROWSER) docs/_build/html/index.html 52 | 53 | release: clean ## package and upload a release 54 | python setup.py sdist upload 55 | python setup.py bdist_wheel upload 56 | 57 | sdist: clean ## package 58 | python setup.py sdist 59 | ls -l dist 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # django-mptt-comments 2 | 3 | 拓展 django 官方的评论库,为评论提供无限层级的支持。 4 | 5 | ## 安装 6 | 7 | 8 | 安装 django-mptt-comments: 9 | 10 | pip install django-mptt-comments 11 | 12 | 将应用及其依赖添加到 `INSTALLED_APPS`: 13 | 14 | INSTALLED_APPS = ( 15 | ... 16 | 'django.contrib.sites', 17 | 'django_comments', 18 | 'django_mptt_comments', 19 | 'captcha', 20 | 'mptt', 21 | ... 22 | ) 23 | 24 | 添加必要的 settings 设置: 25 | 26 | MPTT_COMMENTS_ALLOW_ANONYMOUS = True # True 为允许匿名评论,否则不允许 27 | COMMENTS_APP = 'django_mptt_comments' 28 | SITE_ID = 1 29 | 30 | 添加应用的 URL: 31 | 32 | urlpatterns = [ 33 | ... 34 | url(r'mpttcomments', include('django_mptt_comments.urls')), 35 | url(r'captcha', include('captcha.urls')), 36 | ... 37 | ] 38 | 39 | 因为应用在视图函数外引用了 request,因此需要添加一个中间件支持,并且推荐添加到所有中间件列表的最后: 40 | 41 | 42 | MIDDLEWARE = [ 43 | ... 44 | 'crequest.middleware.CrequestMiddleware', 45 | ] 46 | 47 | 设置数据库(一定先备份原数据库!!!) 48 | 49 | python manage.py migrate 50 | 51 | ## 渲染评论表单 52 | 53 | 为了能够让用户发表评论,我们需要在适当的地方为用户提供一个评论表单,添加表单的方法很简单,打开模板文件,引入模板标签,渲染模板即可。 54 | 55 | 举个例子,你想为你的某一篇博客文章添加评论表单,假设在模板中,表示博客文章的模板变量为 `post`,那么,可以这样为博客文章渲染一个评论表单: 56 | 57 | {% load mptt_comment_tags %} 58 | {% render_mptt_comment_form for post %} 59 | 60 | 这将渲染 comments/form.html 页面,所以如果你想自定义渲染的表单样式,可以在你的项目的模板目录路径下新增一个 comments/form.html,参考默认模板的内容,按需修改即可。 61 | 62 | ## 渲染回复列表 63 | 64 | 展示某个对象下的全部评论,也可以使用模板标签来完成,例如需要显示博客文章 post 下的全部评论,只需要: 65 | 66 | {% load comments %} 67 | {% render_comment_list for post %} 68 | 69 | 这将渲染 comments/list.html 页面,所以同样可以自定义渲染样式,方法和渲染表单类似。 70 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ============================= 2 | django-mptt-comments 3 | ============================= 4 | 5 | .. image:: https://badge.fury.io/py/django-mptt-comments.svg 6 | :target: https://badge.fury.io/py/django-mptt-comments 7 | 8 | .. image:: https://travis-ci.org/zmrenwu/django-mptt-comments.svg?branch=master 9 | :target: https://travis-ci.org/zmrenwu/django-mptt-comments 10 | 11 | .. image:: https://codecov.io/gh/zmrenwu/django-mptt-comments/branch/master/graph/badge.svg 12 | :target: https://codecov.io/gh/zmrenwu/django-mptt-comments 13 | 14 | writting... 15 | 16 | Documentation 17 | ------------- 18 | 19 | The full documentation is at https://django-mptt-comments.readthedocs.io. 20 | 21 | Quickstart 22 | ---------- 23 | 24 | Install django-mptt-comments:: 25 | 26 | pip install django-mptt-comments 27 | 28 | Add it to your `INSTALLED_APPS`: 29 | 30 | .. code-block:: python 31 | 32 | INSTALLED_APPS = ( 33 | ... 34 | 'django_mptt_comments.apps.DjangoMpttCommentsConfig', 35 | ... 36 | ) 37 | 38 | Add django-mptt-comments's URL patterns: 39 | 40 | .. code-block:: python 41 | 42 | from django_mptt_comments import urls as django_mptt_comments_urls 43 | 44 | 45 | urlpatterns = [ 46 | ... 47 | url(r'^', include(django_mptt_comments_urls)), 48 | ... 49 | ] 50 | 51 | Features 52 | -------- 53 | 54 | * TODO 55 | 56 | Running Tests 57 | ------------- 58 | 59 | Does the code actually work? 60 | 61 | :: 62 | 63 | source /bin/activate 64 | (myenv) $ pip install tox 65 | (myenv) $ tox 66 | 67 | Credits 68 | ------- 69 | 70 | Tools used in rendering this package: 71 | 72 | * Cookiecutter_ 73 | * `cookiecutter-djangopackage`_ 74 | 75 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 76 | .. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage 77 | -------------------------------------------------------------------------------- /django_mptt_comments/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.1.0' 2 | 3 | from django.urls import reverse 4 | 5 | 6 | def get_model(): 7 | from .models import MPTTComment 8 | return MPTTComment 9 | 10 | 11 | def get_form(): 12 | from .forms import MPTTCommentForm 13 | return MPTTCommentForm 14 | 15 | 16 | def get_form_target(): 17 | return reverse('mptt-comments-post-comment') 18 | -------------------------------------------------------------------------------- /django_mptt_comments/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from .models import MPTTComment 4 | 5 | admin.site.register(MPTTComment) 6 | -------------------------------------------------------------------------------- /django_mptt_comments/apps.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 2 | from django.apps import AppConfig 3 | 4 | 5 | class DjangoMpttCommentsConfig(AppConfig): 6 | name = 'django_mptt_comments' 7 | -------------------------------------------------------------------------------- /django_mptt_comments/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django_comments.forms import CommentForm 3 | 4 | from captcha.fields import CaptchaField 5 | from crequest.middleware import CrequestMiddleware 6 | 7 | 8 | class MPTTCommentForm(CommentForm): 9 | parent = forms.IntegerField(required=False, widget=forms.HiddenInput) 10 | 11 | def __init__(self, target_object, data=None, initial=None, parent=None, **kwargs): 12 | self.user = kwargs.pop('user', None) 13 | self.parent = parent 14 | if initial is None: 15 | initial = {} 16 | initial.update({'parent': self.parent}) 17 | super(MPTTCommentForm, self).__init__(target_object, data=data, initial=initial, **kwargs) 18 | if self.user is not None: 19 | if self.user.is_authenticated: 20 | self.fields['email'].required = False 21 | self.fields['name'].required = False 22 | else: 23 | self.fields['captcha'] = CaptchaField() 24 | else: 25 | current_request = CrequestMiddleware.get_request() 26 | if current_request.user.is_authenticated: 27 | self.fields['email'].required = False 28 | self.fields['name'].required = False 29 | else: 30 | self.fields['captcha'] = CaptchaField() 31 | 32 | def get_comment_create_data(self, **kwargs): 33 | data = super(MPTTCommentForm, self).get_comment_create_data(**kwargs) 34 | parent = self.cleaned_data.get('parent') 35 | data['parent_id'] = parent 36 | return data 37 | -------------------------------------------------------------------------------- /django_mptt_comments/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-08-30 11:52 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | import django_mptt_comments.models 7 | import mptt.fields 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | initial = True 13 | 14 | dependencies = [ 15 | ('contenttypes', '0002_remove_content_type_name'), 16 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 17 | ('sites', '0002_alter_domain_unique'), 18 | ] 19 | 20 | operations = [ 21 | migrations.CreateModel( 22 | name='MPTTComment', 23 | fields=[ 24 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 25 | ('object_pk', models.TextField(verbose_name='object ID')), 26 | ('user_name', models.CharField(blank=True, max_length=50, verbose_name="user's name")), 27 | ('user_email', models.EmailField(blank=True, max_length=254, verbose_name="user's email address")), 28 | ('user_url', models.URLField(blank=True, verbose_name="user's URL")), 29 | ('comment', models.TextField(max_length=3000, verbose_name='comment')), 30 | ('submit_date', models.DateTimeField(db_index=True, default=None, verbose_name='date/time submitted')), 31 | ('ip_address', models.GenericIPAddressField(blank=True, null=True, unpack_ipv4=True, verbose_name='IP address')), 32 | ('is_public', models.BooleanField(default=True, help_text='Uncheck this box to make the comment effectively disappear from the site.', verbose_name='is public')), 33 | ('is_removed', models.BooleanField(default=False, help_text='Check this box if the comment is inappropriate. A "This comment has been removed" message will be displayed instead.', verbose_name='is removed')), 34 | ('comment_html', django_mptt_comments.models.MarkedTextField('comment', blank=True, editable=False, verbose_name='comment (html)')), 35 | ('lft', models.PositiveIntegerField(db_index=True, editable=False)), 36 | ('rght', models.PositiveIntegerField(db_index=True, editable=False)), 37 | ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)), 38 | ('level', models.PositiveIntegerField(db_index=True, editable=False)), 39 | ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='content_type_set_for_mpttcomment', to='contenttypes.ContentType', verbose_name='content type')), 40 | ('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='children', to='django_mptt_comments.MPTTComment', verbose_name='parent comment')), 41 | ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sites.Site')), 42 | ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='mpttcomment_comments', to=settings.AUTH_USER_MODEL, verbose_name='user')), 43 | ], 44 | options={ 45 | 'verbose_name': 'mptt comment', 46 | 'verbose_name_plural': 'mptt comments', 47 | 'ordering': ['-submit_date'], 48 | 'permissions': [('can_moderate', 'Can moderate comments')], 49 | 'abstract': False, 50 | }, 51 | ), 52 | ] 53 | -------------------------------------------------------------------------------- /django_mptt_comments/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/django_mptt_comments/migrations/__init__.py -------------------------------------------------------------------------------- /django_mptt_comments/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import markdown 3 | from django.db import models 4 | from django.db.models import TextField 5 | from django.utils.translation import ugettext_lazy as _ 6 | from django_comments.models import CommentAbstractModel 7 | from mptt.models import MPTTModel, TreeForeignKey 8 | 9 | import bleach 10 | 11 | from .utils import bleach_value 12 | 13 | 14 | class MarkedTextField(TextField): 15 | """ 16 | A TextField that populate value from ``source`` field, 17 | then convert the value to marked value (using markdown library). 18 | """ 19 | description = _("Marked text") 20 | 21 | def __init__(self, source, *args, **kwargs): 22 | self.source = source 23 | kwargs.setdefault('editable', False) 24 | super(TextField, self).__init__(*args, **kwargs) 25 | 26 | def pre_save(self, model_instance, add): 27 | instance = model_instance 28 | value = None 29 | 30 | for attr in self.source.split('.'): 31 | value = getattr(instance, attr) 32 | instance = value 33 | 34 | if value is None or value == '': 35 | return value 36 | 37 | extensions = [ 38 | 'markdown.extensions.extra', 39 | 'markdown.extensions.codehilite', 40 | ] 41 | 42 | md = markdown.Markdown(extensions=extensions) 43 | value = md.convert(value) 44 | value = bleach_value(value) 45 | value = bleach.linkify(value) 46 | 47 | setattr(model_instance, self.attname, value) 48 | 49 | return value 50 | 51 | def deconstruct(self): 52 | name, path, args, kwargs = super(TextField, self).deconstruct() 53 | args.append(self.source) 54 | 55 | return name, path, args, kwargs 56 | 57 | 58 | class MPTTComment(MPTTModel, CommentAbstractModel): 59 | parent = TreeForeignKey('self', verbose_name=_('parent comment'), blank=True, null=True, 60 | related_name='children', on_delete=models.SET_NULL) 61 | comment_html = MarkedTextField(source='comment', verbose_name=_('comment (html)'), blank=True) 62 | 63 | class Meta(CommentAbstractModel.Meta): 64 | ordering = ['-submit_date'] 65 | verbose_name = _('mptt comment') 66 | verbose_name_plural = _('mptt comments') 67 | 68 | class MPTTMeta: 69 | order_insertion_by = ['submit_date'] 70 | -------------------------------------------------------------------------------- /django_mptt_comments/static/css/django_mptt_comments.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/django_mptt_comments/static/css/django_mptt_comments.css -------------------------------------------------------------------------------- /django_mptt_comments/static/img/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/django_mptt_comments/static/img/.gitignore -------------------------------------------------------------------------------- /django_mptt_comments/static/js/django_mptt_comments.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/django_mptt_comments/static/js/django_mptt_comments.js -------------------------------------------------------------------------------- /django_mptt_comments/templates/django_mptt_comments/base.html: -------------------------------------------------------------------------------- 1 | 2 | {% comment %} 3 | As the developer of this package, don't place anything here if you can help it 4 | since this allows developers to have interoperability between your template 5 | structure and their own. 6 | 7 | Example: Developer melding the 2SoD pattern to fit inside with another pattern:: 8 | 9 | {% extends "base.html" %} 10 | {% load static %} 11 | 12 | 13 | {% block extra_js %} 14 | 15 | 16 | {% block javascript %} 17 | 18 | {% endblock javascript %} 19 | 20 | {% endblock extra_js %} 21 | {% endcomment %} 22 | -------------------------------------------------------------------------------- /django_mptt_comments/templates/django_mptt_comments/reply.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |
9 | {{ mpttcomment.submit_date }} - {{ mpttcomment.name }} 10 |
11 |

{{ mpttcomment.comment_html|safe }}

12 |
13 | {% include 'comments/form.html' with form=form %} 14 | 15 | 16 | -------------------------------------------------------------------------------- /django_mptt_comments/templatetags/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/django_mptt_comments/templatetags/__init__.py -------------------------------------------------------------------------------- /django_mptt_comments/templatetags/mptt_comment_tags.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | from django_comments.templatetags.comments import RenderCommentFormNode 3 | 4 | import django_mptt_comments 5 | 6 | register = template.Library() 7 | 8 | 9 | class RenderMPTTCommentFormNode(RenderCommentFormNode): 10 | def get_form(self, context): 11 | obj = self.get_object(context) 12 | user = context['request'].user 13 | if obj: 14 | return django_mptt_comments.get_form()(obj, user=user) 15 | else: 16 | return None 17 | 18 | 19 | @register.tag 20 | def render_mptt_comment_form(parser, token): 21 | return RenderMPTTCommentFormNode.handle_token(parser, token) 22 | -------------------------------------------------------------------------------- /django_mptt_comments/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from django.conf.urls import url, include 3 | 4 | from . import views 5 | 6 | # app_name = 'django_mptt_comments' 7 | urlpatterns = [ 8 | url(r'^post/$', views.post_mptt_comment, name='mptt-comments-post-comment'), 9 | url(r'^reply/(?P[0-9]+)/$', views.ReplyView.as_view(), name='mptt_comments_reply'), 10 | url(r'^success/$', 11 | views.ReplySuccessView.as_view(), 12 | name='comment_success'), 13 | url('', include('django_comments.urls')), 14 | ] 15 | -------------------------------------------------------------------------------- /django_mptt_comments/utils.py: -------------------------------------------------------------------------------- 1 | import bleach 2 | 3 | BLEACH_ALLOWED_TAGS = ['p', 'pre', 'blockquote', 'ol', 'ul', 'li', 'dl', 'dt', 'dd', 'figure', 'figcaption', 'hr', 'a', 4 | 'em', 'strong', 'cite', 'q', 'dfn', 'abbr', 'time', 'code', 'br', 'i', 'b', 'u', 's', 'sub', 5 | 'sup', 6 | 'ins', 'del', 'img', 'table', 'tr', 'td', 'th', 'caption', 'tbody', 'thead', 'tfoot', 'colgroup', 7 | 'col', 8 | 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'acronym', 'span'] 9 | 10 | BLEACH_ALLOWED_ATTRIBUTES = { 11 | 'a': ['href', 'title'], 12 | 'abbr': ['title'], 13 | 'acronym': ['title'], 14 | 'span': ['class'], 15 | '*': ['id'], 16 | 'img': ['src'], 17 | } 18 | 19 | 20 | def bleach_value(value, tags=BLEACH_ALLOWED_TAGS, attributes=BLEACH_ALLOWED_ATTRIBUTES): 21 | return bleach.clean(value, tags=tags, attributes=attributes) 22 | -------------------------------------------------------------------------------- /django_mptt_comments/views.py: -------------------------------------------------------------------------------- 1 | import django_comments 2 | from django.conf import settings 3 | from django.contrib.auth.decorators import login_required 4 | from django.core.exceptions import ObjectDoesNotExist 5 | from django.views.generic import DetailView, RedirectView 6 | from django.views.generic.edit import FormMixin 7 | from django_comments.views.comments import post_comment 8 | 9 | from .forms import MPTTCommentForm 10 | from .models import MPTTComment 11 | 12 | if settings.MPTT_COMMENTS_ALLOW_ANONYMOUS: 13 | post_mptt_comment = post_comment 14 | else: 15 | post_mptt_comment = login_required(post_comment) 16 | 17 | 18 | class ReplyView(FormMixin, DetailView): 19 | model = MPTTComment 20 | form_class = MPTTCommentForm 21 | pk_url_kwarg = 'parent' 22 | template_name = 'django_mptt_comments/reply.html' 23 | 24 | def get_form_kwargs(self): 25 | kwargs = super(ReplyView, self).get_form_kwargs() 26 | kwargs.update({ 27 | 'target_object': self.object.content_object, 28 | 'parent': self.object.pk, 29 | 'user': self.request.user 30 | }) 31 | return kwargs 32 | 33 | 34 | class ReplySuccessView(RedirectView): 35 | def get_redirect_url(self, *args, **kwargs): 36 | self.url = self.comment.get_absolute_url() 37 | return super(ReplySuccessView, self).get_redirect_url(*args, **kwargs) 38 | 39 | def get(self, request, *args, **kwargs): 40 | self.comment = None 41 | if 'c' in request.GET: 42 | try: 43 | self.comment = django_comments.get_model().objects.get( 44 | pk=request.GET['c']) 45 | except (ObjectDoesNotExist, ValueError): 46 | pass 47 | if self.comment and self.comment.is_public: 48 | return super(ReplySuccessView, self).get(request, *args, **kwargs) 49 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/complexity.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/complexity.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/complexity" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/complexity" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # complexity documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jul 9 22:26:36 2013. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | cwd = os.getcwd() 22 | parent = os.path.dirname(cwd) 23 | sys.path.append(parent) 24 | 25 | import django_mptt_comments 26 | 27 | # -- General configuration ----------------------------------------------------- 28 | 29 | # If your documentation needs a minimal Sphinx version, state it here. 30 | #needs_sphinx = '1.0' 31 | 32 | # Add any Sphinx extension module names here, as strings. They can be extensions 33 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 34 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ['_templates'] 38 | 39 | # The suffix of source filenames. 40 | source_suffix = '.rst' 41 | 42 | # The encoding of source files. 43 | #source_encoding = 'utf-8-sig' 44 | 45 | # The master toctree document. 46 | master_doc = 'index' 47 | 48 | # General information about the project. 49 | project = u'django-mptt-comments' 50 | copyright = u'2018, Xueguang Yang' 51 | 52 | # The version info for the project you're documenting, acts as replacement for 53 | # |version| and |release|, also used in various other places throughout the 54 | # built documents. 55 | # 56 | # The short X.Y version. 57 | version = django_mptt_comments.__version__ 58 | # The full version, including alpha/beta/rc tags. 59 | release = django_mptt_comments.__version__ 60 | 61 | # The language for content autogenerated by Sphinx. Refer to documentation 62 | # for a list of supported languages. 63 | #language = None 64 | 65 | # There are two options for replacing |today|: either, you set today to some 66 | # non-false value, then it is used: 67 | #today = '' 68 | # Else, today_fmt is used as the format for a strftime call. 69 | #today_fmt = '%B %d, %Y' 70 | 71 | # List of patterns, relative to source directory, that match files and 72 | # directories to ignore when looking for source files. 73 | exclude_patterns = ['_build'] 74 | 75 | # The reST default role (used for this markup: `text`) to use for all documents. 76 | #default_role = None 77 | 78 | # If true, '()' will be appended to :func: etc. cross-reference text. 79 | #add_function_parentheses = True 80 | 81 | # If true, the current module name will be prepended to all description 82 | # unit titles (such as .. function::). 83 | #add_module_names = True 84 | 85 | # If true, sectionauthor and moduleauthor directives will be shown in the 86 | # output. They are ignored by default. 87 | #show_authors = False 88 | 89 | # The name of the Pygments (syntax highlighting) style to use. 90 | pygments_style = 'sphinx' 91 | 92 | # A list of ignored prefixes for module index sorting. 93 | #modindex_common_prefix = [] 94 | 95 | # If true, keep warnings as "system message" paragraphs in the built documents. 96 | #keep_warnings = False 97 | 98 | 99 | # -- Options for HTML output --------------------------------------------------- 100 | 101 | # The theme to use for HTML and HTML Help pages. See the documentation for 102 | # a list of builtin themes. 103 | html_theme = 'default' 104 | 105 | # Theme options are theme-specific and customize the look and feel of a theme 106 | # further. For a list of options available for each theme, see the 107 | # documentation. 108 | #html_theme_options = {} 109 | 110 | # Add any paths that contain custom themes here, relative to this directory. 111 | #html_theme_path = [] 112 | 113 | # The name for this set of Sphinx documents. If None, it defaults to 114 | # " v documentation". 115 | #html_title = None 116 | 117 | # A shorter title for the navigation bar. Default is the same as html_title. 118 | #html_short_title = None 119 | 120 | # The name of an image file (relative to this directory) to place at the top 121 | # of the sidebar. 122 | #html_logo = None 123 | 124 | # The name of an image file (within the static path) to use as favicon of the 125 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 126 | # pixels large. 127 | #html_favicon = None 128 | 129 | # Add any paths that contain custom static files (such as style sheets) here, 130 | # relative to this directory. They are copied after the builtin static files, 131 | # so a file named "default.css" will overwrite the builtin "default.css". 132 | html_static_path = ['_static'] 133 | 134 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 135 | # using the given strftime format. 136 | #html_last_updated_fmt = '%b %d, %Y' 137 | 138 | # If true, SmartyPants will be used to convert quotes and dashes to 139 | # typographically correct entities. 140 | #html_use_smartypants = True 141 | 142 | # Custom sidebar templates, maps document names to template names. 143 | #html_sidebars = {} 144 | 145 | # Additional templates that should be rendered to pages, maps page names to 146 | # template names. 147 | #html_additional_pages = {} 148 | 149 | # If false, no module index is generated. 150 | #html_domain_indices = True 151 | 152 | # If false, no index is generated. 153 | #html_use_index = True 154 | 155 | # If true, the index is split into individual pages for each letter. 156 | #html_split_index = False 157 | 158 | # If true, links to the reST sources are added to the pages. 159 | #html_show_sourcelink = True 160 | 161 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 162 | #html_show_sphinx = True 163 | 164 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 165 | #html_show_copyright = True 166 | 167 | # If true, an OpenSearch description file will be output, and all pages will 168 | # contain a tag referring to it. The value of this option must be the 169 | # base URL from which the finished HTML is served. 170 | #html_use_opensearch = '' 171 | 172 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 173 | #html_file_suffix = None 174 | 175 | # Output file base name for HTML help builder. 176 | htmlhelp_basename = 'django-mptt-commentsdoc' 177 | 178 | 179 | # -- Options for LaTeX output -------------------------------------------------- 180 | 181 | latex_elements = { 182 | # The paper size ('letterpaper' or 'a4paper'). 183 | #'papersize': 'letterpaper', 184 | 185 | # The font size ('10pt', '11pt' or '12pt'). 186 | #'pointsize': '10pt', 187 | 188 | # Additional stuff for the LaTeX preamble. 189 | #'preamble': '', 190 | } 191 | 192 | # Grouping the document tree into LaTeX files. List of tuples 193 | # (source start file, target name, title, author, documentclass [howto/manual]). 194 | latex_documents = [ 195 | ('index', 'django-mptt-comments.tex', u'django-mptt-comments Documentation', 196 | u'Xueguang Yang', 'manual'), 197 | ] 198 | 199 | # The name of an image file (relative to this directory) to place at the top of 200 | # the title page. 201 | #latex_logo = None 202 | 203 | # For "manual" documents, if this is true, then toplevel headings are parts, 204 | # not chapters. 205 | #latex_use_parts = False 206 | 207 | # If true, show page references after internal links. 208 | #latex_show_pagerefs = False 209 | 210 | # If true, show URL addresses after external links. 211 | #latex_show_urls = False 212 | 213 | # Documents to append as an appendix to all manuals. 214 | #latex_appendices = [] 215 | 216 | # If false, no module index is generated. 217 | #latex_domain_indices = True 218 | 219 | 220 | # -- Options for manual page output -------------------------------------------- 221 | 222 | # One entry per manual page. List of tuples 223 | # (source start file, name, description, authors, manual section). 224 | man_pages = [ 225 | ('index', 'django-mptt-comments', u'django-mptt-comments Documentation', 226 | [u'Xueguang Yang'], 1) 227 | ] 228 | 229 | # If true, show URL addresses after external links. 230 | #man_show_urls = False 231 | 232 | 233 | # -- Options for Texinfo output ------------------------------------------------ 234 | 235 | # Grouping the document tree into Texinfo files. List of tuples 236 | # (source start file, target name, title, author, 237 | # dir menu entry, description, category) 238 | texinfo_documents = [ 239 | ('index', 'django-mptt-comments', u'django-mptt-comments Documentation', 240 | u'Xueguang Yang', 'django-mptt-comments', 'One line description of project.', 241 | 'Miscellaneous'), 242 | ] 243 | 244 | # Documents to append as an appendix to all manuals. 245 | #texinfo_appendices = [] 246 | 247 | # If false, no module index is generated. 248 | #texinfo_domain_indices = True 249 | 250 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 251 | #texinfo_show_urls = 'footnote' 252 | 253 | # If true, do not generate a @detailmenu in the "Top" node's menu. 254 | #texinfo_no_detailmenu = False 255 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. complexity documentation master file, created by 2 | sphinx-quickstart on Tue Jul 9 22:26:36 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to django-mptt-comments's documentation! 7 | ================================================================= 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | readme 15 | installation 16 | usage 17 | contributing 18 | authors 19 | history 20 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Installation 3 | ============ 4 | 5 | At the command line:: 6 | 7 | $ easy_install django-mptt-comments 8 | 9 | Or, if you have virtualenvwrapper installed:: 10 | 11 | $ mkvirtualenv django-mptt-comments 12 | $ pip install django-mptt-comments 13 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\complexity.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\complexity.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Usage 3 | ===== 4 | 5 | To use django-mptt-comments in a project, add it to your `INSTALLED_APPS`: 6 | 7 | .. code-block:: python 8 | 9 | INSTALLED_APPS = ( 10 | ... 11 | 'django_mptt_comments.apps.DjangoMpttCommentsConfig', 12 | ... 13 | ) 14 | 15 | Add django-mptt-comments's URL patterns: 16 | 17 | .. code-block:: python 18 | 19 | from django_mptt_comments import urls as django_mptt_comments_urls 20 | 21 | 22 | urlpatterns = [ 23 | ... 24 | url(r'^', include(django_mptt_comments_urls)), 25 | ... 26 | ] 27 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | ##Example Project for django_mptt_comments 2 | 3 | This example is provided as a convenience feature to allow potential users to try the app straight from the app repo without having to create a django project. 4 | 5 | It can also be used to develop the app in place. 6 | 7 | To run this example, follow these instructions: 8 | 9 | 1. Navigate to the `example` directory 10 | 2. Install the requirements for the package: 11 | 12 | pip install -r requirements.txt 13 | 14 | 3. Make and apply migrations 15 | 16 | python manage.py makemigrations 17 | 18 | python manage.py migrate 19 | 20 | 4. Run the server 21 | 22 | python manage.py runserver 23 | 24 | 5. Access from the browser at `http://127.0.0.1:8000` 25 | -------------------------------------------------------------------------------- /example/blog/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/example/blog/__init__.py -------------------------------------------------------------------------------- /example/blog/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from .models import Post 4 | 5 | 6 | class PostAdmin(admin.ModelAdmin): 7 | list_display = ['title', 'body', 'created'] 8 | 9 | 10 | admin.site.register(Post, PostAdmin) 11 | -------------------------------------------------------------------------------- /example/blog/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-08-29 14:27 2 | 3 | from django.db import migrations, models 4 | import django.utils.timezone 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | initial = True 10 | 11 | dependencies = [ 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='Post', 17 | fields=[ 18 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 19 | ('title', models.CharField(max_length=100)), 20 | ('body', models.TextField()), 21 | ('created', models.DateTimeField(default=django.utils.timezone.now)), 22 | ], 23 | options={ 24 | 'ordering': ['created'], 25 | }, 26 | ), 27 | ] 28 | -------------------------------------------------------------------------------- /example/blog/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/example/blog/migrations/__init__.py -------------------------------------------------------------------------------- /example/blog/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.utils import timezone 3 | from django.urls import reverse 4 | 5 | 6 | class Post(models.Model): 7 | title = models.CharField(max_length=100) 8 | body = models.TextField() 9 | created = models.DateTimeField(default=timezone.now) 10 | 11 | class Meta: 12 | ordering = ['created'] 13 | 14 | def __str__(self): 15 | return self.title 16 | 17 | def get_absolute_url(self): 18 | return reverse('blog:detail', kwargs={'pk': self.pk}) 19 | -------------------------------------------------------------------------------- /example/blog/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from django.conf.urls import url 3 | 4 | from . import views 5 | 6 | app_name = 'blog' 7 | urlpatterns = [ 8 | url(r'^$', views.IndexView.as_view(), name='index'), 9 | url(r'^posts/(?P\d+)$', views.PostDetailView.as_view(), name='detail'), 10 | ] 11 | -------------------------------------------------------------------------------- /example/blog/views.py: -------------------------------------------------------------------------------- 1 | from django.views.generic import ListView, DetailView 2 | 3 | from django_mptt_comments.models import MPTTComment 4 | from .models import Post 5 | 6 | 7 | class IndexView(ListView): 8 | model = Post 9 | template_name = 'blog/index.html' 10 | 11 | 12 | class PostDetailView(DetailView): 13 | model = Post 14 | template_name = 'blog/detail.html' 15 | -------------------------------------------------------------------------------- /example/db_tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/example/db_tools/__init__.py -------------------------------------------------------------------------------- /example/example/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jukanntenn/django-mptt-comments/14c9b949d93a43c36357660282033f391195f629/example/example/__init__.py -------------------------------------------------------------------------------- /example/example/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for example project. 3 | 4 | Generated by Cookiecutter Django Package 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.9/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | # Quick-start development settings - unsuitable for production 19 | # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ 20 | 21 | # SECURITY WARNING: keep the secret key used in production secret! 22 | SECRET_KEY = "voeo0(b!25j!34k3hogn^&$vbq-*qq7g6l=oz6hfwpgnb6xim9" 23 | 24 | # SECURITY WARNING: don't run with debug turned on in production! 25 | DEBUG = True 26 | 27 | ALLOWED_HOSTS = [] 28 | 29 | # Application definition 30 | 31 | INSTALLED_APPS = [ 32 | 'django.contrib.admin', 33 | 'django.contrib.auth', 34 | 'django.contrib.contenttypes', 35 | 'django.contrib.sessions', 36 | 'django.contrib.messages', 37 | 'django.contrib.staticfiles', 38 | "django.contrib.sites", 39 | 'django_mptt_comments', 40 | 41 | # if your app has other dependencies that need to be added to the site 42 | # they should be added here 43 | "django_comments", 44 | 'captcha', 45 | 'blog', 46 | 'crequest', 47 | 'mptt', 48 | ] 49 | 50 | COMMENTS_APP = 'django_mptt_comments' 51 | SITE_ID = 1 52 | 53 | MIDDLEWARE = [ 54 | 'django.middleware.security.SecurityMiddleware', 55 | 'django.contrib.sessions.middleware.SessionMiddleware', 56 | 'django.middleware.common.CommonMiddleware', 57 | 'django.middleware.csrf.CsrfViewMiddleware', 58 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 59 | 'django.contrib.messages.middleware.MessageMiddleware', 60 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 61 | 'crequest.middleware.CrequestMiddleware', 62 | ] 63 | 64 | ROOT_URLCONF = 'example.urls' 65 | 66 | TEMPLATES = [ 67 | { 68 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 69 | 'DIRS': [os.path.join(BASE_DIR, 'templates'), ], 70 | 'APP_DIRS': True, 71 | 'OPTIONS': { 72 | 'context_processors': [ 73 | 'django.template.context_processors.debug', 74 | 'django.template.context_processors.request', 75 | 'django.contrib.auth.context_processors.auth', 76 | 'django.contrib.messages.context_processors.messages', 77 | ], 78 | }, 79 | }, 80 | ] 81 | 82 | WSGI_APPLICATION = 'example.wsgi.application' 83 | 84 | # Database 85 | # https://docs.djangoproject.com/en/1.9/ref/settings/#databases 86 | 87 | DATABASES = { 88 | 'default': { 89 | 'ENGINE': 'django.db.backends.sqlite3', 90 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 91 | } 92 | } 93 | 94 | # Password validation 95 | # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators 96 | 97 | AUTH_PASSWORD_VALIDATORS = [ 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 106 | }, 107 | { 108 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 109 | }, 110 | ] 111 | 112 | # Internationalization 113 | # https://docs.djangoproject.com/en/1.9/topics/i18n/ 114 | 115 | LANGUAGE_CODE = 'en-us' 116 | 117 | TIME_ZONE = 'UTC' 118 | 119 | USE_I18N = True 120 | 121 | USE_L10N = True 122 | 123 | USE_TZ = True 124 | 125 | # Static files (CSS, JavaScript, Images) 126 | # https://docs.djangoproject.com/en/1.9/howto/static-files/ 127 | 128 | STATIC_URL = '/static/' 129 | 130 | MPTT_COMMENTS_ALLOW_ANONYMOUS = True 131 | -------------------------------------------------------------------------------- /example/example/urls.py: -------------------------------------------------------------------------------- 1 | """example URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.9/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import url, include 17 | from django.contrib import admin 18 | 19 | urlpatterns = [ 20 | url(r'^admin/', admin.site.urls), 21 | url(r'', include('django_mptt_comments.urls')), 22 | url(r'', include('blog.urls')), 23 | url(r'', include('captcha.urls')), 24 | ] 25 | -------------------------------------------------------------------------------- /example/example/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for example project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /example/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /example/requirements.txt: -------------------------------------------------------------------------------- 1 | # Your app requirements. 2 | -r ../requirements_test.txt 3 | 4 | # Your app in editable mode. 5 | -e ../ 6 | -------------------------------------------------------------------------------- /example/templates/blog/detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'django_mptt_comments/base.html' %} 2 | {% load comments %} 3 | {% load mptt_comment_tags %} 4 | {% block content %} 5 |

{{ post.title }}

6 |

{{ post.body }}

7 |
8 |

Comments

9 | {% render_mptt_comment_form for post %} 10 | {% render_comment_list for post %} 11 |
12 | {% endblock %} 13 | -------------------------------------------------------------------------------- /example/templates/blog/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'django_mptt_comments/base.html' %} 2 | {% block content %} 3 |

All Posts

4 |
5 | {% for post in post_list %} 6 | {{ post.title }} 7 |

created at {{ post.created }}

8 |

{{ post.body }}

9 | {% endfor %} 10 |
11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /example/templates/comments/form.html: -------------------------------------------------------------------------------- 1 | {% load comments i18n %} 2 | {#
{% csrf_token %}#} 3 | {# {% if next %}#} 4 | {#
{% endif %}#} 5 | {# {% for field in form %}#} 6 | {# {% if field.is_hidden %}#} 7 | {#
{{ field }}
#} 8 | {# {% else %}#} 9 | {# {% if field.errors %}{{ field.errors }}{% endif %}#} 10 | {#