Permalink
Browse files

Merge branch '1.0'

  • Loading branch information...
coordt committed Jul 22, 2012
2 parents e4d5e03 + 4d02374 commit 252129b4e43897b7371ee2a126538c9229167580
Showing with 3,495 additions and 279 deletions.
  1. +2 −1 .gitignore
  2. 0 README → README.rst
  3. +0 −13 data/UPDATE_04-11-11.SQL
  4. BIN doc_src/_build/doctrees/customizing_staffmember.doctree
  5. BIN doc_src/_build/doctrees/environment.pickle
  6. BIN doc_src/_build/doctrees/getting_started.doctree
  7. BIN doc_src/_build/doctrees/index.doctree
  8. BIN doc_src/_build/doctrees/reference/index.doctree
  9. BIN doc_src/_build/doctrees/reference/settings.doctree
  10. BIN doc_src/_build/doctrees/reference/staff_fields.doctree
  11. +5 −4 doc_src/conf.py
  12. +99 −0 doc_src/customizing_staffmember.rst
  13. +41 −0 doc_src/getting_started.rst
  14. +24 −0 doc_src/includes/mystaffadmin.py
  15. +12 −0 doc_src/includes/mystaffmodel.py
  16. +20 −9 doc_src/index.rst
  17. +0 −3 doc_src/installation.rst
  18. +11 −0 doc_src/reference/index.rst
  19. +36 −0 doc_src/reference/settings.rst
  20. +110 −0 doc_src/reference/staff_fields.rst
  21. BIN doc_src/staff.png
  22. +1 −1 docs/.buildinfo
  23. BIN docs/_images/staff.png
  24. +99 −0 docs/_sources/customizing_staffmember.txt
  25. +41 −0 docs/_sources/getting_started.txt
  26. +20 −9 docs/_sources/index.txt
  27. +11 −0 docs/_sources/reference/index.txt
  28. +36 −0 docs/_sources/reference/settings.txt
  29. +110 −0 docs/_sources/reference/staff_fields.txt
  30. BIN docs/_static/ajax-loader.gif
  31. +35 −4 docs/_static/basic.css
  32. BIN docs/_static/comment-bright.png
  33. BIN docs/_static/comment-close.png
  34. BIN docs/_static/comment.png
  35. +6 −6 docs/_static/doctools.js
  36. BIN docs/_static/down-pressed.png
  37. BIN docs/_static/down.png
  38. +92 −50 docs/_static/searchtools.js
  39. +4 −1 docs/_static/sidebar.js
  40. +7 −0 docs/_static/underscore.js
  41. BIN docs/_static/up-pressed.png
  42. BIN docs/_static/up.png
  43. +808 −0 docs/_static/websupport.js
  44. +375 −0 docs/customizing_staffmember.html
  45. +175 −11 docs/genindex.html
  46. +151 −0 docs/getting_started.html
  47. +47 −16 docs/index.html
  48. BIN docs/objects.inv
  49. +123 −0 docs/reference/index.html
  50. +137 −0 docs/reference/settings.html
  51. +243 −0 docs/reference/staff_fields.html
  52. +12 −7 docs/search.html
  53. +1 −1 docs/searchindex.js
  54. 0 example/mystaff/__init__.py
  55. +24 −0 example/mystaff/admin.py
  56. +13 −0 example/mystaff/models.py
  57. +86 −0 example/mystaff/templates/admin/edit_inline/staff.html
  58. +85 −0 example/mystaff/templates/admin/edit_inline/staff13.html
  59. +1 −0 example/settings.py
  60. +23 −9 setup.py
  61. +13 −8 staff/__init__.py
  62. +18 −10 staff/admin.py
  63. +15 −12 staff/fields.py
  64. +3 −2 staff/forms.py
  65. +84 −71 staff/models.py
  66. +16 −0 staff/settings.py
  67. +86 −0 staff/templates/admin/edit_inline/staff.html
  68. +85 −0 staff/templates/admin/edit_inline/staff13.html
  69. +21 −6 staff/tests.py
  70. +5 −5 staff/urls.py
  71. +23 −20 staff/views.py
View
@@ -9,4 +9,5 @@ media/js/*.r*.js
media/css/*.r*.css
*DS_Store
*.egg-info
-
+MANIFEST
+dist/
View
File renamed without changes.
View
@@ -1,13 +0,0 @@
-ALTER TABLE staff_staffmember ADD COLUMN photo_height integer;
-ALTER TABLE staff_staffmember ALTER COLUMN photo_height SET STORAGE PLAIN;
-ALTER TABLE staff_staffmember ALTER COLUMN photo_height SET DEFAULT 0;
-
-ALTER TABLE staff_staffmember ADD COLUMN photo_width integer;
-ALTER TABLE staff_staffmember ALTER COLUMN photo_width SET STORAGE PLAIN;
-ALTER TABLE staff_staffmember ALTER COLUMN photo_width SET DEFAULT 0;
-
-ALTER TABLE staff_staffmember ADD COLUMN twitter character varying(100);
-ALTER TABLE staff_staffmember ALTER COLUMN twitter SET STORAGE EXTENDED;
-
-ALTER TABLE staff_staffmember ADD COLUMN website character varying(200);
-ALTER TABLE staff_staffmember ALTER COLUMN website SET STORAGE EXTENDED;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
@@ -17,6 +17,7 @@
# 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.append(os.path.abspath('..'))
+import staff
os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings'
# -- General configuration -----------------------------------------------------
@@ -38,17 +39,17 @@
master_doc = 'index'
# General information about the project.
-project = u'staff'
-copyright = u'2009, me'
+project = u'django-staff'
+copyright = u'2012, Calloway Open Source Development'
# 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 = '0.1'
+version = staff.get_version(short=True)
# The full version, including alpha/beta/rc tags.
-release = '0.1'
+release = staff.get_version()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -0,0 +1,99 @@
+=======================
+Customizing StaffMember
+=======================
+
+While the :py:class:`StaffMember` model is meant to be general, sometimes you need something extra. You can create your own subclass of :py:class:`StaffMember` for tweaking. In the example project you can browse the ``mystaff`` app. To test it out:
+
+#. Comment out ``'staff',`` from ``INSTALLED_APPS`` in ``settings.py``
+#. Uncomment ``'mystaff',`` from ``INSTALLED_APPS`` in ``settings.py``
+#. Delete the ``dev.db`` file
+#. Run ``./manage.py syncdb``
+#. Create a new superuser when prompted
+
+
+.. contents::
+ :depth: 1
+ :local:
+ :backlinks: top
+
+Create the custom class
+=======================
+
+Your custom :py:class:`StaffMember` model is going to subclass :py:class:`BaseStaffMember`, which is an abstract version of ``StaffMember``. Add your additional fields to the class.
+
+.. literalinclude:: includes/mystaffmodel.py
+ :linenos:
+ :emphasize-lines: 7-8
+
+Connect the signal
+==================
+
+You need to manually connect the ``post_save`` signal to a function that keeps your custom staff member class in sync.
+
+.. literalinclude:: includes/mystaffmodel.py
+ :linenos:
+ :emphasize-lines: 2,5,11-12
+
+
+#. Import :py:func:`get_staff_updater` from ``staff.models``. See line 5 in the example.
+#. Execute it, passing in your model, and assign it to a variable. See line 11 in the example.
+#. Import ``post_save`` from ``django.db.models.signals``. See line 2 in the example.
+#. Finally connect the ``post_save`` signal to your staff updater variable as in line 12 in the example.
+
+Create your admin class
+=======================
+
+The admin class is more complicated. It consists of three parts: customizing the :py:class:`StaffMemberAdmin` class, creating a custom :py:class:`UserAdmin`, and finally swapping out the currently registered ``UserAdmin`` class with yours.
+
+Your own admin class
+--------------------
+
+Your admin class simply needs to redefine the fieldsets and model of the :py:class:`StaffMemberAdmin` class.
+
+.. literalinclude:: includes/mystaffadmin.py
+ :linenos:
+ :emphasize-lines: 4,6,9-15
+
+The class is very straightforward. Since we only added one field, ``github``, we copy the ``fieldsets`` value from the base class and add that field in.
+
+Then we set the model to our new model.
+
+Making a custom User admin class
+--------------------------------
+
+We need to add an inline class to the current :py:class:`UserAdmin`.
+
+.. literalinclude:: includes/mystaffadmin.py
+ :linenos:
+ :emphasize-lines: 2,17-21
+
+This is merely sublassing the existing :py:class:`UserAdmin` and adding our own ``inlines`` attribute equal to a list containing the new admin class defined above.
+
+Re-registering the UserAdmin
+----------------------------
+
+Now we carefully swap the old ``UserAdmin`` with our ``UserAdmin`` subclass.
+
+.. literalinclude:: includes/mystaffadmin.py
+ :linenos:
+ :emphasize-lines: 1,3,23-24
+
+Django's admin has the ability to both register an admin class and unregister an admin class. After removing any admin classes associated with the :py:class:`User` class, we register and associate our custom user admin class.
+
+Gather the templates
+====================
+
+Django staff includes a set of templates for various Django versions. Since we'll remove ``'staff'`` from ``INSTALLED_APPS``, Django won't find them any more. We need to copy them into either the project's templates directory or your application's template directory.
+
+The templates, named ``staff.html`` and ``staff13.html``, need to go into::
+
+ templates
+ admin
+ edit_inline
+ staff.html
+ staff13.html
+
+Remove staff from INSTALLED_APPS
+================================
+
+If Django Staff is still included in your ``INSTALLED_APPS`` setting, you'll have a bit of redundancy. Make sure that ``'staff'`` is not in that list. It still must remain available to your new application, so don't don't uninstall the library.
@@ -0,0 +1,41 @@
+===============
+Getting Started
+===============
+
+.. contents::
+ :depth: 1
+ :local:
+ :backlinks: top
+
+Installation
+============
+
+#. ``pip install django-staff``
+
+#. Add to ``INSTALLED_APPS`` in ``settings.py``
+
+How it works
+============
+
+#. Django Staff modifies (monkey patches) Django's built-in :py:class:`User` model's admin, adding an inline form to the :py:class:`Staff` model.
+
+#. Django Staff registers a listener to updates to the :py:class:`User` model.
+
+#. Three possible actions can happen when a :py:class:`User` is created or changed:
+
+ #. A staff object is created, linked to the user object and permission is added for all available sites.
+
+ #. The existing staff object is updated, keeping the first name, last name and e-mail in sync and also confirming the active status of the staff object.
+
+ #. The existing staff object is marked as inactive
+
+Using Django Staff
+==================
+
+#. Create a new :py:class:`User`
+
+#. Make sure their ``staff status`` is checked
+
+#. Click the ``Save and continue editing`` button.
+
+#. When the page reloads, you'll notice the additional fields at the bottom of the page.
@@ -0,0 +1,24 @@
+from django.contrib.auth.models import User
+from django.contrib.auth.admin import UserAdmin
+from django.contrib import admin
+from staff.admin import StaffMemberAdmin
+
+from .models import MyStaffMember
+
+
+class MyStaffMemberAdmin(StaffMemberAdmin):
+ fieldsets = (
+ ('Personal Info', {'fields': ('bio', 'photo', 'website', 'phone',)}),
+ ('Social Media', {'fields': ('github', 'twitter', 'facebook', 'google_plus')}),
+ ('Responsibilities', {'fields': ('sites',)}),
+ )
+ model = MyStaffMember
+
+class MyStaffUserAdmin(UserAdmin):
+ """
+ Subclasses the UserAdmin to add the staffmember as an inline.
+ """
+ inlines = [MyStaffMemberAdmin, ]
+
+admin.site.unregister(User)
+admin.site.register(User, MyStaffUserAdmin)
@@ -0,0 +1,12 @@
+from django.db import models
+from django.db.models.signals import post_save
+from django.contrib.auth.models import User
+
+from staff.models import BaseStaffMember, get_staff_updater
+
+class MyStaffMember(BaseStaffMember):
+ github = models.CharField(max_length=50, blank=True)
+
+
+update_staff_member = get_staff_updater(MyStaffMember)
+post_save.connect(update_staff_member, sender=User)
View
@@ -1,18 +1,29 @@
-.. app documentation master file, created by
- sphinx-quickstart on Wed Oct 21 13:18:22 2009.
- You can adapt this file completely to your liking, but it should at least
- contain the root `toctree` directive.
+========================
+Django Staff v |version|
+========================
-Welcome to app's documentation!
-===============================
+.. image:: staff.png
+ :alt: Django Staff Logo
-Contents:
+
+Goals
+=====
+
+In the Django Authentication package all users use the same model/profile. This can be a drawback if you have lots of users and you want different information stored for your staff members, such as bio, contact info, etc. It is also handy for linking to models for author fields so the lookup is quicker.
+
+The staff models are automatically created and managed by the ``is_staff`` property of ``Users``. The staff profile is automatically added to the ``User`` admin screen.
+
+Contents
+========
.. toctree::
:maxdepth: 2
:glob:
-
- installation
+
+ getting_started
+ customizing_staffmember
+ reference/index
+
Indices and tables
View
@@ -1,3 +0,0 @@
-============
-Installation
-============
@@ -0,0 +1,11 @@
+=========
+Reference
+=========
+
+.. toctree::
+ :maxdepth: 2
+ :glob:
+
+ settings
+ staff_fields
+
@@ -0,0 +1,36 @@
+========
+Settings
+========
+
+.. contents::
+ :depth: 1
+ :local:
+ :backlinks: top
+
+Default Settings
+================
+
+.. code-block:: python
+
+ DEFAULT_SETTINGS = {
+ 'PHOTO_STORAGE': settings.DEFAULT_FILE_STORAGE,
+ 'ORDERING': ('last_name', 'first_name'),
+ }
+
+.. _photo_storage_setting:
+
+PHOTO_STORAGE
+=============
+
+**Default:** ``DEFAULT_FILE_STORAGE``
+
+How you wish to store photos of staff members
+
+.. _ordering_setting:
+
+ORDERING
+========
+
+**Default:** ``('last_name', 'first_name')``
+
+How the staff members are ordered in lists by default.
Oops, something went wrong.

0 comments on commit 252129b

Please sign in to comment.