Commit 9a7c0451 by Piotr Mitros

Better logging. Tested and fixed bugs in previous commits

parent 25ca62d9
...@@ -32,12 +32,12 @@ class UserProfile(models.Model): ...@@ -32,12 +32,12 @@ class UserProfile(models.Model):
def get_meta(self): def get_meta(self):
js_str = self.meta js_str = self.meta
if not js: if not js_str:
js = dict() js_str = dict()
else: else:
js = json.reads(self.meta) js_str = json.loads(self.meta)
return js return js_str
def set_meta(self,js): def set_meta(self,js):
self.meta = json.dumps(js) self.meta = json.dumps(js)
......
import datetime
import json import json
import logging import logging
import random import random
...@@ -16,6 +17,7 @@ from django.db import connection ...@@ -16,6 +17,7 @@ from django.db import connection
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from django.shortcuts import redirect from django.shortcuts import redirect
from mitxmako.shortcuts import render_to_response, render_to_string from mitxmako.shortcuts import render_to_response, render_to_string
from mako import exceptions
from django_future.csrf import ensure_csrf_cookie from django_future.csrf import ensure_csrf_cookie
...@@ -373,7 +375,7 @@ def confirm_email_change(request, key): ...@@ -373,7 +375,7 @@ def confirm_email_change(request, key):
meta = up.get_meta() meta = up.get_meta()
if 'old_emails' not in meta: if 'old_emails' not in meta:
meta['old_emails'] = [] meta['old_emails'] = []
meta['old_emails'].append(user.email) meta['old_emails'].append([user.email, datetime.datetime.now().isoformat()])
up.set_meta(meta) up.set_meta(meta)
up.save() up.save()
user.email = pec.new_email user.email = pec.new_email
...@@ -450,7 +452,7 @@ def accept_name_change(request): ...@@ -450,7 +452,7 @@ def accept_name_change(request):
meta = up.get_meta() meta = up.get_meta()
if 'old_names' not in meta: if 'old_names' not in meta:
meta['old_names'] = [] meta['old_names'] = []
meta['old_names'].append(up.name) meta['old_names'].append([up.name, pnc.rationale, datetime.datetime.now().isoformat()])
up.set_meta(meta) up.set_meta(meta)
up.name = pnc.new_name up.name = pnc.new_name
......
...@@ -3,7 +3,7 @@ from ${old_email} to ${new_email}. If you did not make this request, ...@@ -3,7 +3,7 @@ from ${old_email} to ${new_email}. If you did not make this request,
please contact the course staff immediately. Contact information is please contact the course staff immediately. Contact information is
listed at: listed at:
https://${sitename}/t/mitx_help.html https://${ site }/t/mitx_help.html
We keep a log of old e-mails, so if this request was unintentional, we We keep a log of old e-mails, so if this request was unintentional, we
can investigate. can investigate.
...@@ -109,7 +109,7 @@ $(function() { ...@@ -109,7 +109,7 @@ $(function() {
if(data.success){ if(data.success){
$("#apply_name_change").html("<h1>Your request has been submitted.</h1><p>We'll send you an e-mail if we approve the change or need further information. Please allow for up to a week for us to process your request.</p>"); $("#apply_name_change").html("<h1>Your request has been submitted.</h1><p>We'll send you an e-mail if we approve the change or need further information. Please allow for up to a week for us to process your request.</p>");
} else { } else {
$("#apply_name_change_error").html(data.error); $("#change_name_error").html(data.error);
} }
}); });
log_event("profile", {"type":"name_change_request", log_event("profile", {"type":"name_change_request",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment