From d6b4521a1097cfc072db3b18f2ec569ac78fbc78 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 13:37:01 -0700 Subject: [PATCH 01/16] Add docstrings describing models --- authorizenet/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/authorizenet/models.py b/authorizenet/models.py index c1cfe0b..716aa8c 100644 --- a/authorizenet/models.py +++ b/authorizenet/models.py @@ -118,6 +118,9 @@ def create_from_list(self, items): class Response(models.Model): + + """Transaction Response (See Section 4 of AIM Developer Guide)""" + response_code = models.CharField(max_length=2, choices=RESPONSE_CHOICES) response_subcode = models.CharField(max_length=10) response_reason_code = models.CharField(max_length=15) @@ -184,6 +187,9 @@ def __unicode__(self): class CIMResponse(models.Model): + + """Response for CIM API call (See Section 3 in CIM XML Guide)""" + result = models.CharField(max_length=8) result_code = models.CharField(max_length=8, choices=CIM_RESPONSE_CODE_CHOICES) From a90733e20bab33d5f5c4c07d3daddbfe355d1cb8 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 13:46:15 -0700 Subject: [PATCH 02/16] Add empty Sphinx documentation Using command sphinx-quickstart after installing Sphinx --- .gitignore | 1 + docs.rst | 26 ++++++ docs/Makefile | 177 +++++++++++++++++++++++++++++++++++ docs/conf.py | 248 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 22 +++++ docs/make.bat | 242 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 716 insertions(+) create mode 100644 docs.rst create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat diff --git a/.gitignore b/.gitignore index 6a32495..adee736 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/ .coverage .tox htmlcov +docs/_build/ diff --git a/docs.rst b/docs.rst new file mode 100644 index 0000000..8b7f623 --- /dev/null +++ b/docs.rst @@ -0,0 +1,26 @@ +Usage +===== + +Installation +------------ + +Install from `PyPI`_: + +.. code-block:: bash + + $ pip install django-authorizenet + +.. _PyPI: https://pypi.python.org/pypi/django-authorizenet/ + + +Quickstart +---------- + +Add ``authorizenet`` to ``INSTALLED_APPS`` in your settings file: + +.. code-block:: python + + INSTALLED_APPS = ( + ... + 'authorizenet', + ) diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..771b0f1 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,177 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(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/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-authorizenet.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-authorizenet.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/django-authorizenet" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/django-authorizenet" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..a7de350 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,248 @@ +# -*- coding: utf-8 -*- +# +# django-authorizenet documentation build configuration file, created by +# sphinx-quickstart on Mon Jun 10 13:41:57 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'django-authorizenet' +copyright = u'2013, Andrii Kurinnyi' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '2.0' +# The full version, including alpha/beta/rc tags. +release = '2.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'django-authorizenetdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'django-authorizenet.tex', u'django-authorizenet Documentation', + u'Andrii Kurinnyi', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'django-authorizenet', u'django-authorizenet Documentation', + [u'Andrii Kurinnyi'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'django-authorizenet', u'django-authorizenet Documentation', + u'Andrii Kurinnyi', 'django-authorizenet', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..0d0f0d9 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,22 @@ +.. django-authorizenet documentation master file, created by + sphinx-quickstart on Mon Jun 10 13:41:57 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to django-authorizenet's documentation! +=============================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..ddf9701 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,242 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-authorizenet.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-authorizenet.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +:end From 0d1335c37075a2b2339fd58c73d81f30942dc59c Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 13:46:41 -0700 Subject: [PATCH 03/16] Add initial usage documentation --- docs/index.rst | 2 ++ docs/usage.rst | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 docs/usage.rst diff --git a/docs/index.rst b/docs/index.rst index 0d0f0d9..0a40965 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,6 +11,8 @@ Contents: .. toctree:: :maxdepth: 2 + usage + Indices and tables diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..8b7f623 --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,26 @@ +Usage +===== + +Installation +------------ + +Install from `PyPI`_: + +.. code-block:: bash + + $ pip install django-authorizenet + +.. _PyPI: https://pypi.python.org/pypi/django-authorizenet/ + + +Quickstart +---------- + +Add ``authorizenet`` to ``INSTALLED_APPS`` in your settings file: + +.. code-block:: python + + INSTALLED_APPS = ( + ... + 'authorizenet', + ) From c6907eee2eab6595bb75baffc61c00b1b803ac68 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 13:47:30 -0700 Subject: [PATCH 04/16] Make ``python setup.py build_sphinx`` work --- setup.cfg | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..269a021 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,4 @@ +[build_sphinx] +source-dir = docs/ +build-dir = docs/_build +all_files = 1 From 6b4869d0bf62eee3930f37a567bb1540e33ff6e9 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 17:45:18 -0700 Subject: [PATCH 05/16] Note required settings in quick start docs --- docs/usage.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/usage.rst b/docs/usage.rst index 8b7f623..e090cf0 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -24,3 +24,13 @@ Add ``authorizenet`` to ``INSTALLED_APPS`` in your settings file: ... 'authorizenet', ) + +The following settings are required: + +.. code-block:: python + + AUTHNET_DEBUG = True + + AUTHNET_LOGIN_ID = "yOuRl0g1nID" + + AUTHNET_TRANSACTION_KEY = "Tr4n5aCti0nK3y" From 659d0440f2ea05600bb5aae67929fb1e178f9a1b Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 18:24:01 -0700 Subject: [PATCH 06/16] Test that documentation builds --- tox.ini | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 79aa6ce..723a843 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,22 @@ [tox] envlist = py26-1.4, py26-1.5, py26-trunk, - py27-1.4, py27-1.5, py27-trunk + py27-1.4, py27-1.5, py27-trunk, + docs [testenv] commands = coverage run -a --branch setup.py test +[testenv:docs] +changedir = docs +deps = + Sphinx +commands = + sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html + + [testenv:py26-1.4] basepython = python2.6 deps = From 7ce704de1504d3f14c6385c9b28aa99eb6c00462 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 18:24:11 -0700 Subject: [PATCH 07/16] Fix bug in documentation --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 0a40965..1efefdb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,7 +11,7 @@ Contents: .. toctree:: :maxdepth: 2 - usage + usage From 6d41664fd6b9c7840f09ee8cff81438f64b33bcc Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 18:27:31 -0700 Subject: [PATCH 08/16] Add Makefile to document docs and test usage --- Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b07d914 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +all: init test sphinx + +init: + easy_install tox coverage Sphinx + +test: + coverage erase + tox + coverage html + +docs: sphinx + +sphinx: + python setup.py build_sphinx From 995e06463879929923a89cd2ba7467dad31661a0 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Mon, 10 Jun 2013 18:28:12 -0700 Subject: [PATCH 09/16] Add *.egg to .gitignore to ignore httmock eggs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index adee736..3f67b49 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ sample_project/local_settings.py sample_project/dev.db *.egg-info +*.egg build/ dist/ .coverage From ef5ceceac0eadd556982d8805818cf222454bae2 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Sat, 27 Jul 2013 19:34:12 -0700 Subject: [PATCH 10/16] Propagate CIM errors properly --- authorizenet/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/authorizenet/models.py b/authorizenet/models.py index 5f92979..d0196e3 100644 --- a/authorizenet/models.py +++ b/authorizenet/models.py @@ -301,6 +301,7 @@ def push_to_server(self): self.raw_data, self.raw_data, ) + response.raise_if_error() elif self.customer_profile_id: output = create_payment_profile( self.customer_profile.profile_id, @@ -308,6 +309,7 @@ def push_to_server(self): self.raw_data, ) response = output['response'] + response.raise_if_error() self.payment_profile_id = output['payment_profile_id'] else: output = add_profile( @@ -316,13 +318,13 @@ def push_to_server(self): self.raw_data, ) response = output['response'] + response.raise_if_error() self.customer_profile = CustomerProfile.objects.create( customer=self.customer, profile_id=output['profile_id'], sync=False, ) self.payment_profile_id = output['payment_profile_ids'][0] - response.raise_if_error() @property def raw_data(self): From 986e670975736d73608cbeb7d974a9c6aa6ccae1 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Sat, 27 Jul 2013 20:09:04 -0700 Subject: [PATCH 11/16] Add descriptive model and view docstrings --- authorizenet/models.py | 11 +++++++++++ authorizenet/views.py | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/authorizenet/models.py b/authorizenet/models.py index c96afe5..56deac1 100644 --- a/authorizenet/models.py +++ b/authorizenet/models.py @@ -224,6 +224,7 @@ class CustomerProfile(models.Model): profile_id = models.CharField(max_length=50) def save(self, *args, **kwargs): + """If creating new instance, create profile on Authorize.NET also""" data = kwargs.pop('data', {}) sync = kwargs.pop('sync', True) if not self.id and sync: @@ -237,6 +238,7 @@ def delete(self): super(CustomerProfile, self).delete() def push_to_server(self, data): + """Create customer profile for given ``customer`` on Authorize.NET""" output = add_profile(self.customer.pk, data, data) output['response'].raise_if_error() self.profile_id = output['profile_id'] @@ -287,6 +289,7 @@ def __init__(self, *args, **kwargs): return super(CustomerPaymentProfile, self).__init__(*args, **kwargs) def save(self, *args, **kwargs): + """Sync payment profile on Authorize.NET if sync kwarg is not False""" if kwargs.pop('sync', True): self.push_to_server() self.card_code = None @@ -294,6 +297,14 @@ def save(self, *args, **kwargs): super(CustomerPaymentProfile, self).save(*args, **kwargs) def push_to_server(self): + """ + Use appropriate CIM API call to save payment profile to Authorize.NET + + 1. If customer has no profile yet, create one with this payment profile + 2. If payment profile is not on Authorize.NET yet, create it there + 3. If payment profile exists on Authorize.NET update it there + + """ if not self.customer_profile_id: try: self.customer_profile = CustomerProfile.objects.get( diff --git a/authorizenet/views.py b/authorizenet/views.py index 19d1d4a..d557ef1 100644 --- a/authorizenet/views.py +++ b/authorizenet/views.py @@ -126,6 +126,12 @@ def validate_payment_form(self): class PaymentProfileCreateView(CreateView): + """ + View for creating a CustomerPaymentProfile instance + + CustomerProfile instance will be created automatically if needed. + """ + template_name = 'authorizenet/create_payment_profile.html' form_class = CustomerPaymentForm @@ -136,6 +142,10 @@ def get_form_kwargs(self): class PaymentProfileUpdateView(UpdateView): + """ + View for modifying an existing CustomerPaymentProfile instance + """ + template_name = 'authorizenet/update_payment_profile.html' form_class = CustomerPaymentForm From e69816bf2003745abda229f67943f2bd253247fd Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Sat, 27 Jul 2013 20:18:19 -0700 Subject: [PATCH 12/16] Add documentation for CIM --- docs/cim.rst | 42 ++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 1 + 2 files changed, 43 insertions(+) create mode 100644 docs/cim.rst diff --git a/docs/cim.rst b/docs/cim.rst new file mode 100644 index 0000000..928b669 --- /dev/null +++ b/docs/cim.rst @@ -0,0 +1,42 @@ +CIM Usage +========= + +The easiest way to use the CIM support is to use the ``CustomerProfile`` and +``CustomerPaymentProfile`` models provided by the ``authorizenet`` app. These +models map the ORM CRUD operations to Authorize.NET calls, making it easy to +keep your local and remote data in sync. + +Customer profiles contain a one-to-one field ``customer`` which links to the +Django user model by default. This foreign key target may be customized in the +``CUSTOMER_MODEL`` setting in your settings module. + +Using built-in models +--------------------- + +CustomerPaymentProfile Model +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When the ``save()`` method is called on a ``CustomerPaymentProfile`` instance, +the payment profile is created or update on Authorize.NET and saved to the +database. A ``CustomerProfile`` will also be created if the specified +``customer`` doesn't have one yet. + +When the ``delete()`` method is called on a ``CustomerPaymentProfile`` +instance, the payment profile is deleted on Authorize.NET and deleted from the +database. + +Payment Profile Form +~~~~~~~~~~~~~~~~~~~~ + +The ``CustomerPaymentForm`` available in ``authorizenet.forms`` allows a +``CustomerPaymentProfile`` to be easily created or updated for a given +``customer``. This form is just a model form for the +``CustomerPaymentProfile`` model. + +Generic Views +~~~~~~~~~~~~~ + +The ``PaymentProfileCreateView`` and ``PaymentProfileUpdateView`` allow +``CustomerPaymentProfile`` instances can be created and updated with ease. +The ``customer`` argument sent to ``CustomerPaymentForm`` defaults to the +currently authenticated user. diff --git a/docs/index.rst b/docs/index.rst index 1efefdb..5699966 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,6 +12,7 @@ Contents: :maxdepth: 2 usage + cim From 14760ebfd28557294d03e0b9356d6d6f95d66ec9 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Sat, 27 Jul 2013 20:18:31 -0700 Subject: [PATCH 13/16] Add docstring for conf module --- authorizenet/conf.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/authorizenet/conf.py b/authorizenet/conf.py index 45d982a..00b9c4c 100644 --- a/authorizenet/conf.py +++ b/authorizenet/conf.py @@ -1,4 +1,20 @@ -"""Application-specific settings for django-authorizenet""" +""" +Application-specific settings for django-authorizenet + +Available settings: + + - AUTHNET_DEBUG: Set to ``True`` if using Authorize.NET test account + - AUTHNET_LOGIN_ID: Set to value of Authorize.NET login ID + - AUTHNET_TRANSACTION_KEY: Set to value of Authorize.NET transaction key + - AUTHNET_CUSTOMER_MODEL: Used to set customer model used for CIM customers + (defaults to Django user) + - AUTHNET_DELIM_CHAR: Used to set delimiter character for CIM requests + (defaults to "|") + - AUTHNET_FORCE_TEST_REQUEST + - AUTHNET_EMAIL_CUSTOMER + - AUTHNET_MD5_HASH + +""" from django.conf import settings as django_settings From cc045ace8c7a226196bbe89c8a9f0fccdb15eb8b Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Sat, 27 Jul 2013 20:25:25 -0700 Subject: [PATCH 14/16] Fix Django/Python versions in Travis and Tox files --- .travis.yml | 6 ++++++ tox.ini | 16 +++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index bcf1884..85f7437 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: env: - DJANGO=Django==1.4.2 - DJANGO=Django==1.5.0 + - DJANGO=https://github.com/django/django/tarball/stable/1.6.x - DJANGO=https://github.com/django/django/tarball/master install: @@ -17,4 +18,9 @@ script: - coverage run -a setup.py test - coverage report +matrix: + exclude: + - python: 2.6 + env: DJANGO=https://github.com/django/django/tarball/master + after_success: coveralls diff --git a/tox.ini b/tox.ini index 723a843..7434327 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] envlist = - py26-1.4, py26-1.5, py26-trunk, - py27-1.4, py27-1.5, py27-trunk, + py26-1.4, py26-1.5, py26-1.6, + py27-1.4, py27-1.5, py26-1.6, py27-trunk, docs [testenv] -commands = coverage run -a --branch setup.py test +commands = coverage run -a setup.py test [testenv:docs] @@ -29,10 +29,10 @@ deps = django == 1.5 coverage == 3.6 -[testenv:py26-trunk] +[testenv:py26-1.6] basepython = python2.6 deps = - https://github.com/django/django/tarball/master + https://github.com/django/django/tarball/stable/1.6.x coverage == 3.6 @@ -48,6 +48,12 @@ deps = django == 1.5 coverage == 3.6 +[testenv:py27-1.6] +basepython = python2.7 +deps = + https://github.com/django/django/tarball/stable/1.6.x + coverage == 3.6 + [testenv:py27-trunk] basepython = python2.7 deps = From a246d3105f0a2d5a5213d6f50135ad3011e223a4 Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Sat, 27 Jul 2013 21:03:16 -0700 Subject: [PATCH 15/16] Add CONTRIBUTING file --- CONTRIBUTING.rst | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 CONTRIBUTING.rst diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..94099e5 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,51 @@ +Contributing +============ + +Below is a list of tips for submitting issues and pull requests. These are +suggestions and not requirements. + +Submitting Issues +----------------- + +Issues are often easier to reproduce/resolve when they have: + +- A pull request with a failing test demonstrating the issue +- A code example that produces the issue consistently +- A traceback (when applicable) + +Pull Requests +------------- + +When creating a pull request, try to: + +- Write tests if applicable +- Update the `README`_ file if needed +- Update the documentation if needed + +.. _README: README.rst + +Testing +------- + +Please add tests for your code and ensure existing tests don't break. To run +the tests against your code:: + + python setup.py test + +Please use tox to test the code against supported Python and Django versions. +First install tox:: + + pip install tox + +To run tox and generate a coverage report (in ``htmlcov`` directory):: + + make test + +Generating documentation +------------------------ + +To regenerate the documentation use:: + + make docs + +The generated documentation HTML files can be found in ``docs/_build/html``. From c6098834d5d8534985094f53af1d4c33ccf9cddf Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Sat, 27 Jul 2013 21:13:20 -0700 Subject: [PATCH 16/16] Fix version quoting in Travis configuration file --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 85f7437..f4dc81c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: python python: - - "2.6" - - "2.7" + - 2.6 + - 2.7 env: - DJANGO=Django==1.4.2