Permalink
Browse files

Minor style changes

  • Loading branch information...
1 parent 995b938 commit 7288780ab980ff652b0289726b9b0cae1c82020b dot2code Technologies committed Nov 27, 2013
Showing with 397 additions and 368 deletions.
  1. +1 −0 DEVELOPERS.rst
  2. +1 −1 Vagrantfile
  3. +0 −4 extras/vagrant/manifests/default.pp
  4. +2 −2 varnish_bans_manager/__init__.py
  5. +2 −2 varnish_bans_manager/core/__init__.py
  6. +5 −4 varnish_bans_manager/core/context_processors.py
  7. +2 −2 varnish_bans_manager/core/forms/__init__.py
  8. +8 −6 varnish_bans_manager/core/forms/bans.py
  9. +8 −8 varnish_bans_manager/core/forms/base.py
  10. +2 −2 varnish_bans_manager/core/forms/caches/__init__.py
  11. +2 −2 varnish_bans_manager/core/forms/caches/groups.py
  12. +2 −2 varnish_bans_manager/core/forms/caches/nodes.py
  13. +2 −2 varnish_bans_manager/core/forms/settings.py
  14. +13 −12 varnish_bans_manager/core/forms/user.py
  15. +2 −2 varnish_bans_manager/core/forms/users.py
  16. +2 −2 varnish_bans_manager/core/helpers/__init__.py
  17. +17 −12 varnish_bans_manager/core/helpers/cli.py
  18. +2 −2 varnish_bans_manager/core/helpers/commands.py
  19. +4 −4 varnish_bans_manager/core/helpers/csv.py
  20. +2 −2 varnish_bans_manager/core/helpers/http.py
  21. +5 −4 varnish_bans_manager/core/helpers/paginator.py
  22. +2 −2 varnish_bans_manager/core/helpers/views.py
  23. +2 −2 varnish_bans_manager/core/management/__init__.py
  24. +2 −2 varnish_bans_manager/core/management/commands/__init__.py
  25. +2 −2 varnish_bans_manager/core/management/commands/groups.py
  26. +2 −2 varnish_bans_manager/core/management/commands/nodes.py
  27. +3 −3 varnish_bans_manager/core/management/commands/start.py
  28. +3 −3 varnish_bans_manager/core/management/commands/upgrade.py
  29. +2 −2 varnish_bans_manager/core/management/commands/users.py
  30. +13 −10 varnish_bans_manager/core/middleware.py
  31. +2 −2 varnish_bans_manager/core/models/__init__.py
  32. +2 −2 varnish_bans_manager/core/models/ban_submission.py
  33. +28 −21 varnish_bans_manager/core/models/base.py
  34. +2 −2 varnish_bans_manager/core/models/cache.py
  35. +2 −2 varnish_bans_manager/core/models/setting.py
  36. +2 −2 varnish_bans_manager/core/models/user.py
  37. +2 −2 varnish_bans_manager/core/models/user_profile.py
  38. +2 −2 varnish_bans_manager/core/patches/__init__.py
  39. +2 −2 varnish_bans_manager/core/patches/base_management_command.py
  40. +2 −2 varnish_bans_manager/core/signals.py
  41. +2 −2 varnish_bans_manager/core/tasks/__init__.py
  42. +9 −8 varnish_bans_manager/core/tasks/bans.py
  43. +9 −7 varnish_bans_manager/core/tasks/base.py
  44. +2 −2 varnish_bans_manager/core/tasks/kombu.py
  45. +2 −2 varnish_bans_manager/core/tasks/sessions.py
  46. +2 −2 varnish_bans_manager/core/tasks/users.py
  47. +2 −2 varnish_bans_manager/core/templatetags/__init__.py
  48. +13 −10 varnish_bans_manager/core/templatetags/vbm_base_helpers.py
  49. +2 −2 varnish_bans_manager/core/templatetags/vbm_form_helpers.py
  50. +19 −18 varnish_bans_manager/core/templatetags/vbm_widget_helpers.py
  51. +2 −2 varnish_bans_manager/core/views/__init__.py
  52. +2 −2 varnish_bans_manager/core/views/bans.py
  53. +2 −2 varnish_bans_manager/core/views/caches/__init__.py
  54. +2 −2 varnish_bans_manager/core/views/caches/base.py
  55. +2 −2 varnish_bans_manager/core/views/caches/groups.py
  56. +2 −2 varnish_bans_manager/core/views/caches/nodes.py
  57. +2 −2 varnish_bans_manager/core/views/settings.py
  58. +3 −3 varnish_bans_manager/core/views/task.py
  59. +4 −4 varnish_bans_manager/core/views/user.py
  60. +3 −3 varnish_bans_manager/core/views/users.py
  61. +3 −2 varnish_bans_manager/filesystem/__init__.py
  62. +8 −6 varnish_bans_manager/filesystem/forms.py
  63. +9 −7 varnish_bans_manager/filesystem/models.py
  64. +2 −2 varnish_bans_manager/filesystem/sendfile_backends/__init__.py
  65. +2 −2 varnish_bans_manager/filesystem/sendfile_backends/nginx.py
  66. +2 −2 varnish_bans_manager/filesystem/sendfile_backends/stream.py
  67. +2 −2 varnish_bans_manager/filesystem/sendfile_backends/xsendfile.py
  68. +2 −2 varnish_bans_manager/filesystem/signals.py
  69. +2 −2 varnish_bans_manager/filesystem/tasks.py
  70. +2 −2 varnish_bans_manager/filesystem/views.py
  71. +6 −6 varnish_bans_manager/runner.py
  72. +20 −23 varnish_bans_manager/settings.py
  73. +87 −84 varnish_bans_manager/urls.py
  74. +3 −3 varnish_bans_manager/wsgi.py
View
@@ -25,6 +25,7 @@ development environment.
$ python varnish_bans_manager/runner.py syncdb
$ python varnish_bans_manager/runner.py migrate
+ $ python varnish_bans_manager/runner.py createcachetable cache
- Install `Sass <http://sass-lang.com>`_ and `Compass <http://compass-style.org>`_
in your development box (required by ``django-mediagenerator`` asset manager)::
View
@@ -24,5 +24,5 @@ Vagrant.configure('2') do |config|
config.vm.network :private_network, ip: '192.168.100.102'
config.vm.network :public_network
- config.vm.synced_folder '.', '/vagrant', :nfs => false
+ config.vm.synced_folder '.', '/vagrant', :nfs => true
end
@@ -186,16 +186,12 @@
file {'/home/vagrant/source':
ensure => link,
mode => 0644,
- owner => 'vagrant',
- group => 'vagrant',
target => '/vagrant',
}
file {['/vagrant/files']:
ensure => directory,
mode => 0644,
- owner => 'vagrant',
- group => 'vagrant',
}
}
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
import simplejson as json
@@ -12,9 +12,10 @@
def messages(request):
- """
+ '''
Returns a lazy 'messages' context variable (JSON string).
- """
+
+ '''
return {'messages': json.dumps(get_messages(request))}
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
import re
@@ -25,9 +25,10 @@ class TargetField(BetterChoiceField):
}
def load_choices(self, initial=None, expert=False):
- """
+ '''
Build choices from current available groups and nodes.
- """
+
+ '''
groups = Group.objects.all().order_by('weight', 'created_at')
nodes = Node.objects.all().order_by('weight', 'created_at')
# Add nodes not linked to any group.
@@ -45,9 +46,10 @@ def load_choices(self, initial=None, expert=False):
self.initial = self._build_choice_value(initial)
def clean(self, value):
- """
+ '''
Returns a Cache instance.
- """
+
+ '''
value = super(TargetField, self).clean(value)
if value:
cache = self._parse_choice_value(value)
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
from django.core.exceptions import ValidationError
@@ -19,11 +19,11 @@ def __init__(self, default=None, choices=None, *args, **kwargs):
# Fallback fields are never required. Trying to require them should be
# an error.
kwargs.setdefault('required', False)
- assert not kwargs['required'], "No fallback field can be set as "\
- "required."
+ assert not kwargs['required'], 'No fallback field can be set as '\
+ 'required.'
# Set default value and choices.
- assert default is not None or choices, "All fallback fields should "\
- "provide a default value or/and a non-empty choices list."
+ assert default is not None or choices, 'All fallback fields should '\
+ 'provide a default value or/and a non-empty choices list.'
self.default = choices[0] if default is None else default
self.choices = choices
# Done!
@@ -51,8 +51,8 @@ class FallbackBooleanField(FallbackMixinField, BooleanField):
class SortDirectionField(FallbackCharField):
def __init__(self, *args, **kwargs):
- assert 'choices' not in kwargs, "No custom choices can be set for a"\
- "SortDirectionField"
+ assert 'choices' not in kwargs, 'No custom choices can be set for a'\
+ 'SortDirectionField'
kwargs['choices'] = ['asc', 'desc']
super(SortDirectionField, self).__init__(*args, **kwargs)
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
from django import forms
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
from django import forms
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
from django.conf import settings
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
from django import forms
@@ -31,10 +31,10 @@ class LoginForm(forms.Form):
error_messages = {
'invalid_login': _(
- "Please enter a correct e-mail and password. "
- "Note that both fields are case-sensitive."),
+ 'Please enter a correct e-mail and password. '
+ 'Note that both fields are case-sensitive.'),
'inactive': _(
- "This account is inactive."),
+ 'This account is inactive.'),
}
def __init__(self, *args, **kwargs):
@@ -65,18 +65,19 @@ class PasswordResetForm(forms.Form):
"That e-mail address doesn't have an associated "
"user account. Are you sure you've registered?"),
'unusable': _(
- "The user account associated with this e-mail "
- "address cannot reset the password."),
+ 'The user account associated with this e-mail '
+ 'address cannot reset the password.'),
}
def __init__(self, *args, **kwargs):
super(PasswordResetForm, self).__init__(*args, **kwargs)
self.user = None
def clean_email(self):
- """
+ '''
Validates that an active user exists with the given email address.
- """
+
+ '''
email = self.cleaned_data.get('email')
try:
self.user = User.objects.filter(email__iexact=email, is_active=True).order_by('date_joined')[:1].get()
@@ -88,10 +89,10 @@ def clean_email(self):
raise forms.ValidationError(self.error_messages['unknown'])
def save(self, request):
- """
+ '''
Generates a one-use only link for resetting password and sends to the
user.
- """
+ '''
host = request.get_host()
send_templated_mail(
template_name='varnish-bans-manager/core/user/password_reset',
@@ -100,7 +101,7 @@ def save(self, request):
bcc=settings.DEFAULT_BCC_EMAILS,
context={
'name': self.user.first_name or self.user.email,
- 'base_url': "http://%s" % host,
+ 'base_url': 'http://%s' % host,
'reset_url':
(settings.HTTPS_ENABLED and 'https' or 'http') + '://' +
host +
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
from urllib import urlencode
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
from django.utils.translation import ugettext_lazy as _
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-"""
+'''
:copyright: (c) 2012 by the dot2code Team, see AUTHORS.txt for more details.
:license: GPL, see LICENSE.txt for more details.
-"""
+'''
from __future__ import absolute_import
import re
@@ -14,7 +14,7 @@
class Varnish(Telnet):
- """
+ '''
Simple CLI to access a Varnish cache node management port. See:
- https://www.varnish-cache.org/trac/wiki/CLI
@@ -23,7 +23,8 @@ class Varnish(Telnet):
- https://www.varnish-cache.org/docs/3.0/reference/varnish-cli.html
- https://github.com/justquick/python-varnish
- http://code.google.com/p/pyvarnishmport/
- """
+
+ '''
error_messages = {
'missing_secret': _(
'Cache has requested authentication but a secret key was not provided.'),
@@ -53,22 +54,24 @@ def __init__(self, host, port, name, secret=None, version=30, timeout=5):
})
def ban(self, expression):
- """
+ '''
(ban|purge) field operator argument [&& field operator argument [...]]
Invalidates all documents matching the ban expression.
- """
+
+ '''
self._fetch('%s %s' % (
'purge' if self.version < 30 else 'ban',
expression,
))
def ban_list(self):
- """
+ '''
(ban|purge).list
Fetches the list of bans.
- """
+
+ '''
# Fetch list of bans.
content = self._fetch('%s.list' % (
'purge' if self.version < 30 else 'ban',
@@ -87,11 +90,12 @@ def ban_list(self):
return result
def quit(self):
- """
+ '''
quit
Closes the connection to the Varnish CLI.
- """
+
+ '''
self.close()
def _read(self):
@@ -106,10 +110,11 @@ def _auth(self, secret, content):
self._fetch('auth %s' % response.hexdigest())
def _fetch(self, command):
- """
+ '''
Runs a command on a Varnish cache node and return the result.
Return value is a tuple of ((status, length), content).
- """
+
+ '''
self.write(('%s\n' % command).encode("utf8"))
while 1:
buffer = self.read_until('\n').strip()
Oops, something went wrong.

0 comments on commit 7288780

Please sign in to comment.