Markov: add a permission for importing from a log

This commit is contained in:
Brian S. Stephan 2014-04-05 11:20:59 -05:00
parent 399d419824
commit acfcd574b5
2 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,9 @@ class MarkovState(models.Model):
context = models.ForeignKey(MarkovContext)
class Meta:
permissions = {
('import_log_file', "Can import states from a log file"),
}
unique_together = ('context', 'k1', 'k2', 'v')
def __unicode__(self):

View File

@ -5,6 +5,7 @@ markov/views.py --- manipulate markov data
import logging
from django.contrib.auth.decorators import permission_required
from django.http import HttpResponse
from django.shortcuts import render
@ -21,6 +22,7 @@ def index(request):
return HttpResponse()
@permission_required('import_log_file', raise_exception=True)
def import_file(request):
"""Accept a file upload and turn it into markov stuff.