def test_delete_spam_course(self): course = course_model.create_course( **{ "title": "A test course", "hashtag": "ATC-1", "description": "This course is all about ABC", "language": "en", "organizer_uri": '/uri/user/testuser' }) course_model.delete_spam_course(course['uri']) with self.assertRaises(course_model.ResourceDeletedException): course_model.get_course(course['uri'])
def delete_spam(request, course_id): course_uri = course_model.course_id2uri(course_id) course = _get_course_or_404(course_uri) if request.method == "POST": course_model.delete_spam_course(course_uri) return http.HttpResponseRedirect(reverse('home')) context = { } context = _populate_course_context(request, course_id, context) return render_to_response('courses/course_delete_confirmation.html', context, context_instance=RequestContext(request) )
def test_delete_spam_course(self): course = course_model.create_course( **{ "title": "A test course", "hashtag": "ATC-1", "description": "This course is all about ABC", "language": "en", "organizer_uri": '/uri/user/testuser' } ) course_model.delete_spam_course(course['uri']) with self.assertRaises(course_model.ResourceDeletedException): course_model.get_course(course['uri'])
def delete_spam(request, course_id): course_uri = course_model.course_id2uri(course_id) course = _get_course_or_404(course_uri) if request.method == "POST": course_model.delete_spam_course(course_uri) #TODO display splash message to indicate success return http.HttpResponseRedirect(reverse('home')) context = { } context = _populate_course_context(request, course_id, context) return render_to_response('courses/course_delete_confirmation.html', context, context_instance=RequestContext(request) )
def handle_spam_user(username): # delete user spammer = UserProfile.objects.get(username=username) spammer.user.set_unusable_password() spammer.user.save() spammer.deleted = True spammer.save() # delete user comments for spam in spammer.comments.all(): spam.deleted = True spam.save() # delete courses created by user courses = get_courses(organizer_uri=u'/uri/user/{0}'.format(spammer.username)) for course in courses: delete_spam_course(course['uri'])
def handle_spam_user(username): # delete user spammer = UserProfile.objects.get(username=username) spammer.user.set_unusable_password() spammer.user.save() spammer.deleted = True spammer.save() # delete user comments for spam in spammer.comments.all(): spam.deleted = True spam.save() # delete courses created by user courses = get_courses( organizer_uri=u'/uri/user/{0}'.format(spammer.username)) for course in courses: delete_spam_course(course['uri'])