PEP8 cleanup.
This commit is contained in:
parent
2a5c8e02e0
commit
29f7834921
3 changed files with 17 additions and 12 deletions
|
@ -7,4 +7,4 @@ from .models import RadioUser
|
||||||
|
|
||||||
@admin.register(RadioUser)
|
@admin.register(RadioUser)
|
||||||
class RadioUserAdmin(UserAdmin):
|
class RadioUserAdmin(UserAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -8,9 +8,10 @@ from .models import Setting
|
||||||
|
|
||||||
|
|
||||||
def generate_password(length=32):
|
def generate_password(length=32):
|
||||||
possible_characters = string.ascii_letters + string.digits + string.punctuation
|
chars = string.ascii_letters + string.digits + string.punctuation
|
||||||
rng = random.SystemRandom()
|
rng = random.SystemRandom()
|
||||||
return ''.join([rng.choice(possible_characters) for i in range(length)])
|
return ''.join([rng.choice(chars) for i in range(length)])
|
||||||
|
|
||||||
|
|
||||||
def get_len(rawqueryset):
|
def get_len(rawqueryset):
|
||||||
"""
|
"""
|
||||||
|
@ -19,17 +20,21 @@ def get_len(rawqueryset):
|
||||||
"""
|
"""
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
params = ['{}'.format(p) for p in self.params]
|
params = ['{}'.format(p) for p in self.params]
|
||||||
sql = 'SELECT COUNT(*) FROM (' + rawqueryset.raw_query.format(tuple(params)) + ') B;'
|
sql = ''.join(('SELECT COUNT(*) FROM (',
|
||||||
|
rawqueryset.raw_query.format(tuple(params)),
|
||||||
|
') B;'))
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
return row[0]
|
return row[0]
|
||||||
return __len__
|
return __len__
|
||||||
|
|
||||||
|
|
||||||
def get_setting(name):
|
def get_setting(name):
|
||||||
setting = Setting.objects.get(name=name)
|
setting = Setting.objects.get(name=name)
|
||||||
return setting.get()
|
return setting.get()
|
||||||
|
|
||||||
|
|
||||||
def set_setting(name, value, setting_type=None):
|
def set_setting(name, value, setting_type=None):
|
||||||
setting_types = {'Integer': 0, 'Float': 1, 'String': 2, 'Bool': 3}
|
setting_types = {'Integer': 0, 'Float': 1, 'String': 2, 'Bool': 3}
|
||||||
try:
|
try:
|
||||||
|
@ -44,6 +49,6 @@ def set_setting(name, value, setting_type=None):
|
||||||
setting_type=setting_types[setting_type],
|
setting_type=setting_types[setting_type],
|
||||||
data=str(value))
|
data=str(value))
|
||||||
else:
|
else:
|
||||||
error_msg = 'New settings need a type (Integer, Float, String, Bool)'
|
error_msg = 'New settings need type (Integer, Float, String, Bool)'
|
||||||
raise TypeError(error_msg)
|
raise TypeError(error_msg)
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,9 +8,9 @@ CONFIG_DIR = os.path.dirname(SETTINGS_DIR)
|
||||||
PROJECT_DIR = os.path.dirname(CONFIG_DIR)
|
PROJECT_DIR = os.path.dirname(CONFIG_DIR)
|
||||||
BASE_DIR = os.path.dirname(PROJECT_DIR)
|
BASE_DIR = os.path.dirname(PROJECT_DIR)
|
||||||
|
|
||||||
###
|
#
|
||||||
### Django-specific settings
|
# Django-specific settings
|
||||||
###
|
#
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
{
|
{
|
||||||
|
@ -88,10 +88,10 @@ USE_TZ = True
|
||||||
|
|
||||||
WSGI_APPLICATION = 'savepointradio.wsgi.application'
|
WSGI_APPLICATION = 'savepointradio.wsgi.application'
|
||||||
|
|
||||||
###
|
#
|
||||||
### Radio-specific settings
|
# Radio-specific settings
|
||||||
###
|
#
|
||||||
|
|
||||||
RADIO_DJ_EMAIL = config('RADIO_DJ_EMAIL', default='dj@radiostation.net')
|
RADIO_DJ_EMAIL = config('RADIO_DJ_EMAIL', default='dj@radiostation.net')
|
||||||
|
|
||||||
RADIO_DJ_NAME = config('RADIO_DJ_NAME', default='DJ Reinhardt')
|
RADIO_DJ_NAME = config('RADIO_DJ_NAME', default='DJ Reinhardt')
|
||||||
|
|
Loading…
Reference in a new issue