Пример #1
0
def deactivate_discourse(request):
    logger.debug("deactivate_discourse called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = DiscourseManager.delete_user(authinfo.discourse_username)
    if result:
        AuthServicesInfoManager.update_user_discourse_info("", "", request.user)
        logger.info("Successfully deactivated discourse for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to activate discourse for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
Пример #2
0
def activate_discourse(request):
    logger.debug("activate_discourse called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    character = EveManager.get_character_by_id(authinfo.main_char_id)
    logger.debug("Adding discourse user for user %s with main character %s" % (request.user, character))
    result = DiscourseManager.add_user(character.character_name, request.user.email)
    if result[0] != "":
        AuthServicesInfoManager.update_user_discourse_info(result[0], result[1], request.user)
        logger.debug("Updated authserviceinfo for user %s with discourse credentials. Updating groups." % request.user)
        update_discourse_groups.delay(request.user.pk)
        logger.info("Successfully activated discourse for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to activate forum for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")