'Handle all actions from courses view'

def post(self, request):

    if (not request.user.is_staff):
        raise Http404
    action = request.POST.get('action', '')
    track.views.server_track(request, action, {}, page='courses_sysdashboard')
    courses = {course.id: course for course in self.get_courses()}
    if (action == 'add_course'):
        gitloc = request.POST.get('repo_location', '').strip().replace('    ', '').replace(';', '')
        branch = request.POST.get('repo_branch', '').strip().replace('    ', '').replace(';', '')
        self.msg += self.get_course_from_git(gitloc, branch)
    elif (action == 'del_course'):
        course_id = request.POST.get('course_id', '').strip()
        course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
        course_found = False
        if (course_key in courses):
            course_found = True
            course = courses[course_key]
        else:
            try:
                course = get_course_by_id(course_key)
                course_found = True
            except Exception as err:
                self.msg += _('Error    -    cannot    get    course    with    ID    {0}<br/><pre>{1}</pre>').format(course_key, escape(str(err)))
        if course_found:
            self.def_ms.delete_course(course.id, request.user.id)
            self.msg += u"<font    color='red'>{0}    {1}    =    {2}    ({3})</font>".format(_('Deleted'), course.location.to_deprecated_string(), course.id.to_deprecated_string(), course.display_name)
    context = {'datatable': self.make_datatable(), 'msg': self.msg, 'djangopid': os.getpid(), 'modeflag': {'courses': 'active-section'}, 'edx_platform_version': getattr(settings, 'EDX_PLATFORM_VERSION_STRING', '')}
    return render_to_response(self.template_name, context)
