forked from 0x2620/pandora
log backend errors into db
This commit is contained in:
parent
36d5001608
commit
e458fed035
5 changed files with 71 additions and 12 deletions
|
|
@ -108,17 +108,18 @@ def log(request):
|
|||
}
|
||||
'''
|
||||
data = json.loads(request.POST['data'])
|
||||
if not request.user.is_authenticated:
|
||||
if request.user.is_authenticated():
|
||||
user = request.user
|
||||
else:
|
||||
user = None
|
||||
if 'text' in data:
|
||||
l = models.Log(
|
||||
user=user,
|
||||
text=data['text'],
|
||||
line=int(data.get('line', 0)),
|
||||
url=data.get('url', '')
|
||||
)
|
||||
if user:
|
||||
l.user = user
|
||||
l.save()
|
||||
response = json_response()
|
||||
return render_to_json_response(response)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue