Welcome to django-atom’s documentation!¶
Contents:
django-atom¶


A different stuff for Django to faster make a world a better place.
Documentation¶
The full documentation is at https://django-atom.readthedocs.org.
Installation¶
At the command line:
$ easy_install django-atom
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv django-atom
$ pip install django-atom
Django-guardian¶
There is some extensions for django-guardian package.
Forms¶
Tests¶
Example usage¶
from django.core.urlresolvers import reverse
from django.test import TestCase
from atom.ext.guardian.tests import PermissionStatusMixin
from feder.monitorings.factories import MonitoringFactory
from feder.users.factories import UserFactory
class ObjectMixin(object):
def setUp(self):
self.user = UserFactory(username='john')
self.monitoring = self.permission_object = MonitoringFactory()
self.case = CaseFactory(monitoring=self.monitoring)
self.from_user = OutgoingLetterFactory(title='Wniosek',
case__monitoring=self.monitoring)
self.from_institution = IncomingLetterFactory(title='Odpowiedz',
case__monitoring=self.monitoring)
class LetterRssFeedTestCase(ObjectMixin, PermissionStatusMixin, TestCase):
status_anonymous = 200
status_no_permission = 200
permission = []
def get_url(self):
return reverse('letters:rss')
Docstrings¶
-
class
atom.ext.guardian.tests.
PermissionStatusMixin
[source]¶ Mixin to verify object permission status codes for different users
Require user with username=’john’ and password=’pass’
- Attributes:
- permission (list): Description status_anonymous (int): Status code for anonymouser status_has_permission (int): Status code for user with permission status_no_permission (403): Status code for user without permission url (string): url to test
-
get_permission
()[source]¶ Returns the permission to assign for granted permission user
- Returns:
- list: A list of permission in format
`codename.permission_name`
- Raises:
- ImproperlyConfigured: Missing a permission to assign
-
get_url
()[source]¶ Get url to tests
- Returns:
- str: url to test
- Raises:
- ImproperlyConfigured: Missing a url to test
-
permission
= None¶
-
status_anonymous
= 302¶
-
status_has_permission
= 200¶
-
status_no_permission
= 403¶
-
test_status_code_for_privileged_user
()[source]¶ A test for status code of response for privileged user
Grant permission to permission-carrying object and login before test
-
test_status_code_for_signed_user
()[source]¶ A test for status code of response for signed (logged-in) user
Only login before test.
-
url
= None¶
Django-crispy-forms¶
There is some extensions for django-crispy-forms package.
Filters¶
Forms¶
-
class
atom.ext.crispy_forms.forms.
FormsetHelper
(form=None)[source]¶ -
form_method
= 'post'¶
-
form_tag
= False¶
-
-
class
atom.ext.crispy_forms.forms.
HelperMixin
(*args, **kwargs)[source]¶ -
form_helper_cls
¶ alias of
FormHelper
-
-
class
atom.ext.crispy_forms.forms.
SingleButtonMixin
(*args, **kwargs)[source]¶ Dynamically add crispy button to form layout
Usage of mixins is obvious:
from django import forms from atom.ext.crispy_forms.forms import SingleButtonMixin class PersonModelForm(SingleButtonMixin, forms.ModelForm): class Meta: model = Person
HelperMixin
-
action_text
¶ A text of added action submit button.
In standards it detects when forms save or update objects
string – A text used in button
-
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/ad-m/django-atom/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-atom could always use more documentation, whether as part of the official django-atom 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/ad-m/django-atom/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-atom for local development.
Fork the django-atom repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/django-atom.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv django-atom $ cd django-atom/ $ python setup.py develop
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 flake8 and the tests, including testing other Python versions with tox:
$ flake8 atom tests
$ python setup.py test
$ tox
To get flake8 and tox, just pip install them into your virtualenv.
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
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- 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.
- The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check https://travis-ci.org/ad-m/django-atom/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Adam Dobrawy <naczelnik@jawnosc.tk>
Contributors¶
None yet. Why not be the first?
History¶
0.1.0 (2015-08-01)¶
- First release on PyPI.
0.2.0 (2015-08-04)¶
- Added AutocompleteChoiceFilter
- Add CSS-class settings for CrispyFormFilter
- Drop strict requirements for django-tinycontent
0.3.0 (2015-08-04)¶
- Split class to independent package to resolve dependencies issues
0.6.0 (2015-10-25)¶
- A lot
0.10.0 (2015-11-21)¶
- Add asci_slugifier
- Add absolute_import to crispy_forms
0.11.0 (2015-12-10)¶
- Fix support of dj19 by autocomplete_light API changes
0.12.0 (2016-12-4)¶
- Add
atom.ext.guardian.tests.PermissionStatusMixin
0.12.8 (2016-12-16)¶
- Mark code as Python 3 compatible
0.14.0 (2017-06-1)¶
- Add
atom.mixins.AdminTestCaseMixin
0.14.1 (2017-06-1)¶
- Add base class validation in
atom.mixins.AdminTestCaseMixin
0.14.2 (2017-06-1)¶
- Fix username and message in
atom.mixins.AdminTestCaseMixin
0.14.3 (2017-06-1)¶
- Fix django 1.8-1.9 compatibility of
atom.mixins
0.15.0 (2017-07-21)¶
- Add management command
generate_factory
,generate_routers
,generate_serializers
,generate_viewsets
,generate_viewsets_tests
- Add serializer
atom.ext.contenttypes.ContentTypeSerializer
,atom.ext.sites.serializer.SiteSerializer
- Add mixin
atom.ext.rest_framework.ViewSetTestCaseMixin
0.15.1 (2017-08-4)¶
- Fix management commands import
0.15.2 (2017-08-4)¶
- Fix README.rst format
0.15.3 (2017-08-4)¶
- Fix HISTORY.rst format
Docstrings¶
Filters¶
Forms¶
Models¶
-
class
atom.models.
AttachmentBase
(*args, **kwargs)[source]¶ -
class
Meta
[source]¶ -
abstract
= False¶
-
verbose_name
= u'Attachment'¶
-
verbose_name_plural
= u'Attachments'¶
-
-
AttachmentBase.
attachment
¶ The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assigns a file object on assignment so you can do:
>>> with open('/path/to/hello.world', 'r') as f: ... instance.file = File(f)
-
AttachmentBase.
filename
¶
-
class
Views¶
-
class
atom.views.
BaseActionView
(**kwargs)[source]¶ Base view for action on an object. Using this base class requires subclassing to provide a response mixin.