Add endpoint to get user list for a preference

The endpoint includes the key of the desired preference in the URL and
returns the list of users for whom the preference is set (regardless of
the value).
This commit is contained in:
Greg Price
2014-03-10 18:25:32 -04:00
parent 8f01756c6c
commit bbd6f788ad
4 changed files with 77 additions and 2 deletions

View File

@@ -1,11 +1,13 @@
from django.contrib.auth.models import User
from django.core.validators import RegexValidator
from django.db import models
class UserPreference(models.Model):
"""A user's preference, stored as generic text to be processed by client"""
KEY_REGEX = r"[-_a-zA-Z0-9]+"
user = models.ForeignKey(User, db_index=True, related_name="preferences")
key = models.CharField(max_length=255, db_index=True)
key = models.CharField(max_length=255, db_index=True, validators=[RegexValidator(KEY_REGEX)])
value = models.TextField()
class Meta: