Replace namedtuple with an intermediate class

Named Tuples aren't supported on python 2.5
This commit is contained in:
Matthew Jones
2016-01-14 15:38:00 -05:00
parent 08878700ef
commit 7b12954127

View File

@@ -12,7 +12,6 @@ import socket
import sys
import errno
from base64 import b64encode
from collections import namedtuple
# Django
from django.conf import settings
@@ -2970,13 +2969,21 @@ class SettingsList(ListCreateAPIView):
filter_backends = ()
def get_queryset(self):
# TODO: docs
class SettingsIntermediary(object):
def __init__(self, key, description, category, value,
value_type, user):
self.key = key
self.description = description
self.category = category
self.value = value
self.value_type = value_type
self.user = user
if not self.request.user.is_superuser:
# NOTE: Shortcutting the rbac class due to the merging of the settings manifest and the database
# we'll need to extend this more in the future when we have user settings
return []
SettingsTuple = namedtuple('Settings', ['key', 'description', 'category', 'value', 'value_type', 'user'])
all_defined_settings = {s.key: SettingsTuple(s.key,
all_defined_settings = {s.key: SettingsIntermediary(s.key,
s.description,
s.category,
s.value_converted,
@@ -2989,7 +2996,7 @@ class SettingsList(ListCreateAPIView):
settings_actual.append(all_defined_settings[settings_key])
else:
m_entry = manifest_settings[settings_key]
settings_actual.append(SettingsTuple(settings_key,
settings_actual.append(SettingsIntermediary(settings_key,
m_entry['description'],
m_entry['category'],
m_entry['default'],