Skip to content

Commit

Permalink
Merge branch 'release/0.9.0'.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-code committed May 13, 2017
2 parents 9560de0 + df89358 commit afaa003
Show file tree
Hide file tree
Showing 30 changed files with 2,846 additions and 326 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ target/
*.pot
*.py[co]
__pycache__
.vscode/
MANIFEST
dist/
docs/_build/
Expand Down
15 changes: 14 additions & 1 deletion CONTRIBUTORS.md → AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
=======
Credits
=======

The Begining
------------

django-qa was started by Arjun Komath (<[email protected]>) in 2015 as a
way to have a simple and pluggable Q&A App for Django projects.

Development Lead
----------------

* Cristian Vargas <[email protected]>

Contributors
============
------------

Arjun Komath
Cristian Vargas
Sebastian Reyes
Expand Down
107 changes: 107 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
============
Contributing
============

Contributions are welcome, and they are greatly appreciated! Every
little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions
----------------------

Report Bugs
~~~~~~~~~~~

Report bugs at https://github.com/swappsco/django-qa/issues.

If you are reporting a bug, please include:

* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

Fix Bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug"
is open to whoever wants to implement it.

Implement Features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "feature"
is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

django-qa could always use more documentation, whether as part of the
official django-qa docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at https://github.com/swappsco/django-qa/issues.

If you are proposing a feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)

Get Started!
------------

Ready to contribute? Here's how to set up `django-qa` for local development.

1. Fork the `django-qa` repo on GitHub.
2. Clone your fork locally::

$ git clone [email protected]:swappsco/django-qa.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::

$ cd django-qa/
$ mkvirtualenv env
$ source env/bin/activate

4. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass the tests::

$ python runtests.py

6. Commit your changes and push your branch to GitHub::

$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

7. Submit a pull request through the GitHub website.

Pull Request Guidelines
-----------------------

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.7, 3.4, and 3.5; also for Django
1.9 and 1.10 Check https://travis-ci.org/swappsco/django-qa/pull_requests
and make sure that the tests pass for all supported Python and Django versions.

Tips
----

To run a subset of tests::

$ python -m unittest tests.test_django-qa
1,918 changes: 1,918 additions & 0 deletions HISTORY.rst

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include AUTHORS.rst
include CONTRIBUTING.rst
include LICENSE
include README.rst
include CONTRIBUTORS.md
include LICENSE.md
recursive-include qa *.html *.png *.gif *js *.css *jpg *jpeg *svg *py
recursive-include qa/templates *
recursive-include qa/static *
recursive-include qa/migrations *
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.PHONY: clean-pyc clean-build docs help
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
from urllib import pathname2url
except:
from urllib.request import pathname2url

webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"

help:
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'

clean: clean-build clean-pyc

clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr *.egg-info

clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +

test: ## run tests quickly with the default Python
python runtests.py tests

coverage: ## check code coverage quickly with the default Python
coverage run --source django-qa runtests.py tests
coverage report -m
coverage html
open htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/django-qa.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ django-qa
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html

release: clean ## package and upload a release
python setup.py sdist upload
python setup.py bdist_wheel upload

sdist: clean ## package
python setup.py sdist
ls -l dist

history: ## Generate the history report from the git log comments records
rm HISTORY.rst
printf '%s\n' '.. :changelog:' '' 'History' '-------' >> HISTORY.rst
git log --no-merges --pretty=format:'%cd - `#%h <https://github.com/swappsco/django-qa/commit/%H>`_ %n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%n%n* %s%n' >> HISTORY.rst
58 changes: 7 additions & 51 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,66 +41,22 @@ Features
* Support for hit counts with django-hitcounts.
* Questions are categorized by latest, popular and most voted.

Installation
============
Django-QA aims at keeping things simple. To install it you have to do what you would do with most django apps.

Install with pip::

pip install django-qa

Add to INSTALLED_APPS in your project settings:

.. code-block:: python
INSTALLED_APPS = (
...
'qa',
'taggit',
'hitcount',
...
)
Add the package urls to the project:

.. code-block:: python
urlpatterns = [
...,
url(r'^', include('qa.urls')),
...
]
Run migrations::

python manage.py migrate

And that's it!


Settings
========
QA_DESCRIPTION_OPTIONAL (False). This flag disables validation for description field, allowing title only questions.

Django qa uses `django-hitcount <https://github.com/thornomad/django-hitcount>`_ . If you want to have a custom behaviour for the hitcounts feature, feel free to use django-hitcount settings.


About the functionality
=======================
* The package is integrated with the framework authentication process, right now the package defines an user profile linked to Django's user model, this models was created to contain information related to the user's activities inside the package functionalities.
* It has comments on questions and answers.
* It has no support for anonymous questions nor answers or comments.
* It has tagging support through django-taggit.
* It has a basic implementation for score and reputation records.
* The package has no moderation options on none of the models, and has no REST support.

Next steps
==========
With this setup you will have a functional questions and answers section inside of your project. Probably you will need to work on changing the default templates to fit the look and feel of your site.
Some considerations
===================
For better understanding and information, please take a look at the documentation_ and report bugs and issues in the issue panel if you find one.

With this setup you will have a functional questions and answers section inside your project. Probably you will need to work on the default templates to integrate the look and feel of your site.

If your project has an user profile already, you may want to merge it with the data provided by this app (questions, answers, comments, reputation, etc). That requires some extra work, but can be done without using ugly hacks.

The template structure serves as a foundation for your project, but you can (and should) override the defaults to better suit your needs. For example we load bootstrap3 from a CDN, but if your application already has bootstrap in a package you can just extend from your main base template.

The package has no moderation options on none of the models yet and still lacks REST support.

If you think that something essential for this kind of application is missing, you can request a feature by adding an issue to our repository.
.. _documentation: https://django-qa.readthedocs.io/en/latest/?badge=latest
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
version = '0.1.1'
version = '0.9.0'
# The full version, including alpha/beta/rc tags.
release = '0.1.1'
release = '0.9.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
38 changes: 35 additions & 3 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,40 @@ Settings

Available settings:

``QA_DESCRIPTION_OPTIONAL`` This flag disables the validation applied to the 'description' field, allowing title only questions.
The default behaviour is set to ``False``, enforcing the need for a description. If set to ``True``, you will be able to create questions without descriptions.
``QA_SETTINGS`` is dictionary type set of configurations to setting up django-qa, and it comes with the next structure:

.. code-block:: python
Django qa uses `django-hitcount <https://github.com/thornomad/django-hitcount>`_ . If you want to have a custom behaviour for the hitcounts feature, feel free to use django-hitcount settings.
QA_SETTINGS = {
'qa_messages': True,
'qa_description_optional': False,
'reputation': {
'CREATE_QUESTION': 0,
'CREATE_ANSWER': 0,
'CREATE_ANSWER_COMMENT': 0,
'CREATE_QUESTION_COMMENT': 0,
'ACCEPT_ANSWER': 0,
'UPVOTE_QUESTION': 0,
'UPVOTE_ANSWER': 0,
'DOWNVOTE_QUESTION': 0,
'DOWNVOTE_ANSWER': 0,
}
}
The dictionary must be declared inside the project's settings file, and comes with the following keys to configure:

``qa_messages``: Boolean type value. This flag enables the ``django.contrib.messages`` functionality. The default behaviour is set to ``False`` if not implemented accross the whole project and if not declared inside the settings dictionary.
``qa_description_optional``: Boolean type value. This flag disables the validation applied to the 'description' field, allowing title only questions. The default behaviour is set to ``False``, enforcing the need for a description. If set to ``True``, you will be able to create questions without descriptions.
``count_hits``: Boolean type value. This flag disables the Hit Counting behaviour on the ``QuestionDetailView``. The default behaviour is set to ``True``.
``reputation``: is a dictionary structure to define the different values for the concepts with access to the user reputation.
``'CREATE_QUESTION'``: ``Int`` type positive value. Points given to the user when he creates a question.
``'CREATE_ANSWER'``: ``Int`` type positive value. Points given to the user for answering a registered question.
``'CREATE_ANSWER_COMMENT'``: ``Int`` type positive value. Points given to the user for commenting on an answer.
``'CREATE_QUESTION_COMMENT'``: ``Int`` type positive value. Points given to the user for commenting on a question.
``'ACCEPT_ANSWER'``: ``Int`` type positive value. Points given to the user when his answer is accepted as the prefered answer.
``'UPVOTE_QUESTION'``: ``Int`` type positive value. Points given to the voter and to the user qho created the question for upvoting on that question.
``'UPVOTE_ANSWER'``: ``Int`` type positive value. Points given to the voter and to the user who created the answer for upvoting on that answer.
``'DOWNVOTE_QUESTION'``: ``Int`` type positive value. Points taken from the voter and from the user qho created the question for downvoting on that question (to be implemented soon).
``'DOWNVOTE_ANSWER'``: ``Int`` type positive value. Points taken from the voter and from the user who created the answer for downvoting on that answer (to be implemented soon).

Django-QA uses `django-hitcount <https://github.com/thornomad/django-hitcount>`_ . If you want to have a custom behaviour for the hitcounts feature, feel free to use django-hitcount settings.
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import os
from django.core import management

os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
if __name__ == "__main__":
management.execute_from_command_line()
1 change: 1 addition & 0 deletions qa/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'qa.apps.QAConfig'
4 changes: 2 additions & 2 deletions qa/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import admin
from qa.models import (Question, Answer, AnswerComment, AnswerVote,
QuestionComment)
from django_markdown.admin import MarkdownModelAdmin
from qa.models import (Answer, AnswerComment, AnswerVote, Question,
QuestionComment)

admin.site.register(Question)
admin.site.register(Answer, MarkdownModelAdmin)
Expand Down
8 changes: 8 additions & 0 deletions qa/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


class QAConfig(AppConfig):
name = 'qa'

def ready(self):
import qa.signals
14 changes: 10 additions & 4 deletions qa/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from qa.models import UserQAProfile, Question
from django.conf import settings
from django import forms
from django.conf import settings
from qa.models import Question


class QuestionForm(forms.ModelForm):
Expand All @@ -10,5 +10,11 @@ class Meta:

def __init__(self, *args, **kwargs):
super(QuestionForm, self).__init__(*args, **kwargs)
if hasattr(settings, 'QA_DESCRIPTION_OPTIONAL'):
self.fields['description'].required = not settings.QA_DESCRIPTION_OPTIONAL

try:
settings.QA_SETTINGS['qa_description_optional']
self.fields['description'].required = not settings.QA_SETTINGS[
'qa_description_optional']

except KeyError:
pass
Loading

0 comments on commit afaa003

Please sign in to comment.