Diverse Code Cleanups
*Code wurde PEP-8 gerecht formatiert * Kleine Fehler die der PyCharm Inspector beanstandet wurden korrigiert
This commit is contained in:
committed by
Christian Berg
parent
f34281089d
commit
86a0db050d
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 28.09.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from .countries import COUNTRIES
|
||||
from .html_cleaner import HtmlCleaner
|
||||
from .massmailer import MassMailer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 24.11.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from django import forms
|
||||
import datetime
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 08.05.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
@@ -17,10 +17,10 @@ from . import widgets
|
||||
|
||||
class Html5Mixin(object):
|
||||
def widget_attrs(self, widget):
|
||||
'''
|
||||
"""
|
||||
Overwrites the standard Widget Attributes to add some HTML5 Stuff
|
||||
:param widget: A Widget Object
|
||||
'''
|
||||
"""
|
||||
attrs = super(Html5Mixin, self).widget_attrs(widget)
|
||||
if self.required and not isinstance(widget, widgets.CheckboxInput):
|
||||
attrs['required'] = 'required'
|
||||
@@ -199,9 +199,8 @@ class ReCaptchaField(django.forms.fields.CharField):
|
||||
self.required = True
|
||||
super(ReCaptchaField, self).__init__(*args, **kwargs)
|
||||
|
||||
def _check_recaptcha(self, challenge_value, response_value, \
|
||||
remote_ip={}):
|
||||
'''
|
||||
def _check_recaptcha(self, challenge_value, response_value, remote_ip):
|
||||
"""
|
||||
Submits a reCAPTCHA request for verification.
|
||||
Returns RecaptchaResponse for the request
|
||||
|
||||
@@ -209,7 +208,7 @@ class ReCaptchaField(django.forms.fields.CharField):
|
||||
@param response_value: value of recaptcha_response_field
|
||||
@param remoteip -- the user's ip address
|
||||
|
||||
'''
|
||||
"""
|
||||
import urllib
|
||||
import urllib2
|
||||
private_key = settings.RECAPTCHA_PRIVATE_KEY
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 08.05.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from django.db import models
|
||||
from django.db.models import ForeignKey, Model, SET_NULL # @UnusedImport
|
||||
from django.db.models import SET_DEFAULT, ManyToManyField # @UnusedImport
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 05.08.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from django.http import Http404
|
||||
from . import registry
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 08.05.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.forms import widgets
|
||||
from django.forms.util import flatatt
|
||||
@@ -119,9 +119,9 @@ class RangeInput(widgets.TextInput):
|
||||
|
||||
|
||||
class ReCaptchaInput(widgets.Widget):
|
||||
'''
|
||||
"""
|
||||
Der HTML Code von Googles ReCaptcha als Form Widget
|
||||
'''
|
||||
"""
|
||||
recaptcha_challenge_name = 'recaptcha_challenge_field'
|
||||
recaptcha_response_name = 'recaptcha_response_field'
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 19.10.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from BeautifulSoup import BeautifulSoup
|
||||
|
||||
|
||||
@@ -46,10 +46,10 @@ class HtmlCleaner(object):
|
||||
self.clean_attributes(tag)
|
||||
|
||||
def clean_html(self, fragment=''):
|
||||
'''
|
||||
"""
|
||||
Reparses and cleans the html from XSS Attacks until it stops changing.
|
||||
@param fragment:
|
||||
'''
|
||||
"""
|
||||
while True:
|
||||
soup = BeautifulSoup(fragment)
|
||||
self.tag_removed = False
|
||||
|
||||
@@ -653,17 +653,17 @@ class vDDDLists:
|
||||
self.dts = vDDD
|
||||
|
||||
def ical(self):
|
||||
'''
|
||||
"""
|
||||
Generates the text string in the iCalendar format.
|
||||
'''
|
||||
"""
|
||||
dts_ical = [dt.ical() for dt in self.dts]
|
||||
return ",".join(dts_ical)
|
||||
|
||||
def from_ical(ical):
|
||||
'''
|
||||
"""
|
||||
Parses the list of data formats from ical text format.
|
||||
@param ical: ical text format
|
||||
'''
|
||||
"""
|
||||
out = []
|
||||
ical_dates = ical.split(",")
|
||||
for ical_dt in ical_dates:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 06.06.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
import fnmatch
|
||||
from optparse import make_option
|
||||
import os
|
||||
@@ -15,9 +15,9 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
'''
|
||||
"""
|
||||
classdocs
|
||||
'''
|
||||
"""
|
||||
can_import_settings = True
|
||||
help = _("Reads raw CSS from stdin, and writes compressed CSS to stdout.")
|
||||
option_list = BaseCommand.option_list + (
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 06.06.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
import fnmatch
|
||||
import os
|
||||
|
||||
@@ -14,9 +14,9 @@ import jsmin
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
'''
|
||||
"""
|
||||
classdocs
|
||||
'''
|
||||
"""
|
||||
can_import_settings = True
|
||||
help = _("Reads raw CSS from stdin, and writes compressed CSS to stdout.")
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'''
|
||||
"""
|
||||
Created on 06.06.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.management.base import BaseCommand
|
||||
@@ -13,9 +13,9 @@ from scss import parser
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
'''
|
||||
"""
|
||||
classdocs
|
||||
'''
|
||||
"""
|
||||
can_import_settings = True
|
||||
help = _("Compile SCSS rules.")
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ from django.template import loader, Context
|
||||
|
||||
|
||||
class MassMailer(object):
|
||||
'''
|
||||
"""
|
||||
This Class will send E-Mails via an SMTP Connection to multiple recipients.
|
||||
Each E-Mail will be send individually and can be personalized.
|
||||
It will be send as HTML and Plain-Text Message.
|
||||
'''
|
||||
"""
|
||||
context = {}
|
||||
headers = {}
|
||||
subject = None
|
||||
@@ -83,9 +83,9 @@ class MassMailer(object):
|
||||
self.headers[name] = value
|
||||
|
||||
def send(self):
|
||||
'''
|
||||
"""
|
||||
Process the E-Mails and send them
|
||||
'''
|
||||
"""
|
||||
self.process_mails()
|
||||
if len(self.mail_queue) == 0:
|
||||
self.log.info('No recipients for eMail "%s", bye!', self.subject)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
"""
|
||||
Created on 23.05.2011
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from django.utils.html import strip_spaces_between_tags
|
||||
|
||||
|
||||
class CompressHtmlMiddleware(object):
|
||||
'''
|
||||
"""
|
||||
This Middleware compresses the HTML Output at the End. It strips the Spaces
|
||||
between Tags, an at the beginning and the end of the content.
|
||||
'''
|
||||
"""
|
||||
|
||||
def process_response(self, request, response):
|
||||
if 'text/html' in response['Content-Type']:
|
||||
|
||||
@@ -60,7 +60,7 @@ class PermissionRequiredMixin(object):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
# Verify class settings
|
||||
if self.permission_required == None or len(self.permission_required.split(".")) != 2:
|
||||
if self.permission_required is None or len(self.permission_required.split(".")) != 2:
|
||||
raise ImproperlyConfigured("'PermissionRequiredMixin' requires 'permission_required' attribute to be set.")
|
||||
has_permission = request.user.has_perm(self.permission_required)
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
'''
|
||||
"""
|
||||
Created on 25.11.2013
|
||||
|
||||
@author: christian
|
||||
'''
|
||||
"""
|
||||
from django import template
|
||||
from django.conf import settings
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
Reference in New Issue
Block a user