Skip to content

Commit

Permalink
hack
Browse files Browse the repository at this point in the history
  • Loading branch information
emord committed Jul 23, 2015
1 parent 2df5b21 commit a84bc54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
17 changes: 0 additions & 17 deletions django_prbac/fields.py
Expand Up @@ -43,18 +43,6 @@ def to_python(self, value):
else:
raise ValueError('Invalid value for StringListField: %r is neither the correct type nor deserializable' % value)

def get_prep_value(self, value):
"""
Converts the value, which must be a string list, to a comma-separated string,
quoted appropriately. This format is private to the field type so it is not
exposed for customization or any such thing.
"""

if not self.is_string_list(value):
raise ValueError('Invalid value for StringListField: %r' % value)
else:
return django_prbac.csv.line_to_string(value, lineterminator='')

def value_to_string(self, obj):
value = self._get_val_from_obj(obj)
return self.get_prep_value(value)
Expand Down Expand Up @@ -106,8 +94,3 @@ def value_to_string(self, obj):
value = self._get_val_from_obj(obj)
return self.get_prep_value(value)

def get_prep_value(self, value):
if not self.is_string_set(value):
raise ValueError('Invalid value %r for StringSetField' % value)
else:
return super(StringSetField, self).get_prep_value(sorted(value))
10 changes: 9 additions & 1 deletion django_prbac/migrations/0001_initial.py
Expand Up @@ -21,6 +21,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('assignment', json_field.fields.JSONField(default={}, help_text='Assignment from parameters (strings) to values (any JSON-compatible value)', blank=True)),
],
options={
},
bases=(django_prbac.models.ValidatingModel, models.Model),
),
migrations.CreateModel(
Expand All @@ -30,8 +32,10 @@ class Migration(migrations.Migration):
('slug', models.CharField(help_text='The formal slug for this role, which should be unique', unique=True, max_length=256)),
('name', models.CharField(help_text='The friendly name for this role to present to users; this need not be unique.', max_length=256)),
('description', models.TextField(default='', help_text='A long-form description of the intended semantics of this role.', blank=True)),
('parameters', django_prbac.fields.StringSetField(default=[], help_text='A set of strings which are the parameters for this role. Entered as a JSON list.', blank=True)),
('parameters', django_prbac.fields.StringSetField(default={}, help_text='A set of strings which are the parameters for this role. Entered as a JSON list.', blank=True)),
],
options={
},
bases=(django_prbac.models.ValidatingModel, models.Model),
),
migrations.CreateModel(
Expand All @@ -41,16 +45,20 @@ class Migration(migrations.Migration):
('role', models.OneToOneField(related_name='user_role', to='django_prbac.Role')),
('user', models.OneToOneField(related_name='prbac_role', to=settings.AUTH_USER_MODEL)),
],
options={
},
bases=(django_prbac.models.ValidatingModel, models.Model),
),
migrations.AddField(
model_name='grant',
name='from_role',
field=models.ForeignKey(related_name='memberships_granted', to='django_prbac.Role', help_text='The sub-role begin granted membership or permission'),
preserve_default=True,
),
migrations.AddField(
model_name='grant',
name='to_role',
field=models.ForeignKey(related_name='members', to='django_prbac.Role', help_text='The super-role or permission being given'),
preserve_default=True,
),
]
2 changes: 1 addition & 1 deletion django_prbac/models.py
Expand Up @@ -56,7 +56,7 @@ class Role(ValidatingModel, models.Model):
parameters = StringSetField(
help_text='A set of strings which are the parameters for this role. Entered as a JSON list.',
blank=True,
default=[],
default={},
)


Expand Down
2 changes: 1 addition & 1 deletion django_prbac/south_migrations/0003_auto__add_userrole.py
Expand Up @@ -82,4 +82,4 @@ def backwards(self, orm):
}
}

complete_apps = ['django_prbac']
complete_apps = ['django_prbac']

0 comments on commit a84bc54

Please sign in to comment.