Exemplo n.º 1
0
    def send_broadcast_message(group_name, broadcast_message):
        # create to address
        client = xmpp.Client(settings.JABBER_URL)
        client.connect(server=(settings.JABBER_SERVER, settings.JABBER_PORT))
        client.auth(settings.BROADCAST_USER, settings.BROADCAST_USER_PASSWORD, 'broadcast')

        if group_name != 'all':
            group = Group.objects.get(name=group_name)
            for user in group.user_set.all():
                auth_info = AuthServicesInfoManager.get_auth_service_info(user)
                if auth_info:
                    if auth_info.jabber_username != "":
                        to_address = auth_info.jabber_username + '@' + settings.JABBER_URL
                        message = xmpp.Message(to_address, broadcast_message)
                        message.setAttr('type', 'chat')
                        client.send(message)
                        client.Process(1)
        else:
            for user in User.objects.all():
                auth_info = AuthServicesInfoManager.get_auth_service_info(user)
                if auth_info:
                    if auth_info.jabber_username != "":
                        to_address = auth_info.jabber_username + '@' + settings.JABBER_URL
                        message = xmpp.Message(to_address, broadcast_message)
                        message.setAttr('type', 'chat')
                        client.send(message)
                        client.Process(1)

        client.disconnect()
Exemplo n.º 2
0
    def send_broadcast_message(group_name, broadcast_message):
        # create to address
        client = xmpp.Client(settings.JABBER_URL)
        client.connect(server=(settings.JABBER_SERVER, settings.JABBER_PORT))
        client.auth(settings.BROADCAST_USER, settings.BROADCAST_USER_PASSWORD,
                    'broadcast')

        if group_name != 'all':
            group = Group.objects.get(name=group_name)
            for user in group.user_set.all():
                auth_info = AuthServicesInfoManager.get_auth_service_info(user)
                if auth_info:
                    if auth_info.jabber_username != "":
                        to_address = auth_info.jabber_username + '@' + settings.JABBER_URL
                        message = xmpp.Message(to_address, broadcast_message)
                        message.setAttr('type', 'chat')
                        client.send(message)
                        client.Process(1)
        else:
            for user in User.objects.all():
                auth_info = AuthServicesInfoManager.get_auth_service_info(user)
                if auth_info:
                    if auth_info.jabber_username != "":
                        to_address = auth_info.jabber_username + '@' + settings.JABBER_URL
                        message = xmpp.Message(to_address, broadcast_message)
                        message.setAttr('type', 'chat')
                        client.send(message)
                        client.Process(1)

        client.disconnect()
Exemplo n.º 3
0
def activate_teamspeak3(request):
    logger.debug("activate_teamspeak3 called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    character = EveManager.get_character_by_id(authinfo.main_char_id)
    if check_if_user_has_permission(request.user, "blue_member"):
        logger.debug(
            "Adding TS3 user for blue user %s with main character %s" %
            (request.user, character))
        result = Teamspeak3Manager.add_blue_user(character.character_name,
                                                 character.corporation_ticker)
    else:
        logger.debug("Adding TS3 user for user %s with main character %s" %
                     (request.user, character))
        result = Teamspeak3Manager.add_user(character.character_name,
                                            character.corporation_ticker)

    # if its empty we failed
    if result[0] is not "":
        AuthServicesInfoManager.update_user_teamspeak3_info(
            result[0], result[1], request.user)
        logger.debug(
            "Updated authserviceinfo for user %s with TS3 credentials. Updating groups."
            % request.user)
        update_teamspeak3_groups(request.user)
        logger.info("Succesfully activated TS3 for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to activate TS3 for user %s" %
                 request.user)
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 4
0
def reset_ipboard_password(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = IPBoardManager.update_user_password(authinfo.ipboard_username, request.user.email)
    if result != "":
        AuthServicesInfoManager.update_user_ipboard_info(authinfo.ipboard_username, result, request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 5
0
def set_ipboard_password(request):
    logger.debug("set_ipboard_password called by user %s" % request.user)
    error = None
    if request.method == 'POST':
        logger.debug("Received POST request with form.")
        form = ServicePasswordForm(request.POST)
        logger.debug("Form is valid: %s" % form.is_valid())
        if form.is_valid():
            password = form.cleaned_data['password']
            authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
            result = IPBoardManager.update_user_password(authinfo.ipboard_username, request.user.email, plain_password=password)
            if result != "":
                AuthServicesInfoManager.update_user_ipboard_info(authinfo.ipboard_username, result, request.user)
                logger.info("Succesfully reset forum password for user %s" % request.user)
                return HttpResponseRedirect("/services/")
            else:
                logger.error("Failed to install custom ipboard password for user %s" % request.user)
                error = "Failed to install custom password."
        else:
            error = "Invalid password provided"
    else:
        logger.debug("Request is not type POST - providing empty form.")
        form = ServicePasswordForm()

    logger.debug("Rendering form for user %s" % request.user)
    context = {'form': form, 'service': 'IPBoard', 'error': error}
    return render_to_response('registered/service_password.html', context, context_instance=RequestContext(request))
Exemplo n.º 6
0
def timer_view(request):
    logger.debug("timer_view called by user %s" % request.user)
    auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
    char = EveManager.get_character_by_id(auth_info.main_char_id)
    if char:
        corp = EveManager.get_corporation_info_by_id(char.corporation_id)
    else:
        corp = None
    if corp:
        corp_timers = Timer.objects.all().filter(corp_timer=True).filter(
            eve_corp=corp)
    else:
        corp_timers = []
    timer_list = Timer.objects.all()
    closest_timer = None
    if timer_list:
        closest_timer = \
        sorted(list(Timer.objects.all().filter(corp_timer=False)), key=lambda d:  (timezone.now()))[0]
    logger.debug("Determined closest timer is %s" % closest_timer)
    render_items = {
        'timers': Timer.objects.all().filter(corp_timer=False),
        'corp_timers': corp_timers,
        'closest_timer': closest_timer
    }

    return render_to_response('registered/timermanagement.html',
                              render_items,
                              context_instance=RequestContext(request))
Exemplo n.º 7
0
def add_optimer_view(request):
    logger.debug("add_optimer_view called by user %s" % request.user)
    if request.method == 'POST':
    	form = opForm(request.POST)
    	logger.debug("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            #Get Current Time
            post_time = timezone.now()
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            # handle valid form
            op = optimer()
            op.doctrine = form.cleaned_data['doctrine']
            op.system = form.cleaned_data['system']
            op.location = form.cleaned_data['location']
            op.start = form.cleaned_data['start']
            op.duration = form.cleaned_data['duration']
            op.operation_name = form.cleaned_data['operation_name']
            op.fc = form.cleaned_data['fc']
            op.details = form.cleaned_data['details']
            op.create_time = post_time
            op.eve_character = character
            op.save()
            logger.info("User %s created op timer with name %s" % (request.user, op.operation_name))
            return HttpResponseRedirect("/optimer/")
    else:
        logger.debug("Returning new opForm")
        form = opForm()

    render_items = {'form': form}

    return render_to_response('registered/addoperation.html', render_items, context_instance=RequestContext(request))
Exemplo n.º 8
0
def deactivate_services(user):
    logger.debug("Deactivating services for user %s" % user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(user)
    if authinfo.mumble_username and authinfo.mumble_username != "":
        logger.debug("User %s has mumble account %s. Deleting." % (user, authinfo.mumble_username))
        MumbleManager.delete_user(authinfo.mumble_username)
        AuthServicesInfoManager.update_user_mumble_info("", "", user)
    if authinfo.jabber_username and authinfo.jabber_username != "":
        logger.debug("User %s has jabber account %s. Deleting." % (user, authinfo.jabber_username))
        OpenfireManager.delete_user(authinfo.jabber_username)
        AuthServicesInfoManager.update_user_jabber_info("", "", user)
    if authinfo.forum_username and authinfo.forum_username != "":
        logger.debug("User %s has forum account %s. Deleting." % (user, authinfo.forum_username))
        Phpbb3Manager.disable_user(authinfo.forum_username)
        AuthServicesInfoManager.update_user_forum_info("", "", user)
    if authinfo.ipboard_username and authinfo.ipboard_username != "":
        logger.debug("User %s has ipboard account %s. Deleting." % (user, authinfo.ipboard_username))
        IPBoardManager.disable_user(authinfo.ipboard_username)
        AuthServicesInfoManager.update_user_forum_info("", "", user)
    if authinfo.teamspeak3_uid and authinfo.teamspeak3_uid != "":
        logger.debug("User %s has mumble account %s. Deleting." % (user, authinfo.teamspeak3_uid))
        Teamspeak3Manager.delete_user(authinfo.teamspeak3_uid)
        AuthServicesInfoManager.update_user_teamspeak3_info("", "", user)
    if authinfo.discord_uid and authinfo.discord_uid != "":
        logger.debug("User %s has discord account %s. Deleting." % (user, authinfo.discord_uid))
        DiscordManager.delete_user(authinfo.discord_uid)
        AuthServicesInfoManager.update_user_discord_info("", user)
Exemplo n.º 9
0
def add_timer_view(request):
    if request.method == 'POST':
        form = TimerForm(request.POST)

        if form.is_valid():
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            corporation = EveManager.get_corporation_info_by_id(character.corporation_id)

            # calculate future time
            future_time = datetime.timedelta(days=form.cleaned_data['days_left'], hours=form.cleaned_data['hours_left'], minutes=form.cleaned_data['minutes_left'])
            current_time = datetime.datetime.utcnow()
            eve_time = current_time + future_time

            # handle valid form
            timer = Timer()
            timer.details = form.cleaned_data['details']
            timer.system = form.cleaned_data['system']
            timer.planet_moon = form.cleaned_data['planet_moon']
            timer.structure = form.cleaned_data['structure']
            timer.objective = form.cleaned_data['objective']
            timer.eve_time = eve_time
            timer.important = form.cleaned_data['important']
            timer.eve_character = character
            timer.eve_corp = corporation
            timer.user = request.user
            timer.save()
            return HttpResponseRedirect("/timers/")
    else:
        form = TimerForm()

    render_items = {'form': form}

    return render_to_response('registered/addtimer.html', render_items, context_instance=RequestContext(request))
Exemplo n.º 10
0
def api_key_removal(request, api_id):
    logger.debug("api_key_removal called by user %s for api id %s" %
                 (request.user, api_id))
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    # Check if our users main id is in the to be deleted characters
    characters = EveManager.get_characters_by_owner_id(request.user.id)
    if characters is not None:
        for character in characters:
            if character.character_id == authinfo.main_char_id:
                if character.api_id == api_id:
                    # TODO: Remove services also
                    if authinfo.is_blue:
                        logger.debug(
                            "Blue user %s deleting api for main character. Disabling."
                            % request.user)
                        disable_blue_member(request.user)
                    else:
                        logger.debug(
                            "User %s deleting api for main character. Disabling."
                            % request.user)
                        disable_member(request.user, authinfo.main_char_id)

    EveManager.delete_api_key_pair(api_id, request.user.id)
    EveManager.delete_characters_by_api_id(api_id, request.user.id)
    logger.info(
        "Succesfully processed api delete request by user %s for api %s" %
        (request.user, api_id))
    return HttpResponseRedirect("/api_key_management/")
Exemplo n.º 11
0
def reset_teamspeak3_perm(request):
    logger.debug("reset_teamspeak3_perm 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("Deleting TS3 user for user %s" % request.user)
    Teamspeak3Manager.delete_user(authinfo.teamspeak3_uid)

    remove_all_syncgroups_for_service(request.user, "teamspeak3")

    if check_if_user_has_permission(request.user, "blue_member"):
        logger.debug("Generating new permission key for blue user %s with main character %s" % (request.user, character))
        result = Teamspeak3Manager.generate_new_blue_permissionkey(authinfo.teamspeak3_uid, character.character_name,
                                                                   character.corporation_ticker)
    else:
        logger.debug("Generating new permission key for user %s with main character %s" % (request.user, character))
        result = Teamspeak3Manager.generate_new_permissionkey(authinfo.teamspeak3_uid, character.character_name,
                                                              character.corporation_ticker)

    # if blank we failed
    if result != "":
        AuthServicesInfoManager.update_user_teamspeak3_info(result[0], result[1], request.user)
        logger.debug("Updated authserviceinfo for user %s with TS3 credentials. Updating groups." % request.user)
        update_teamspeak3_groups(request.user)
        logger.info("Successfully reset TS3 permission key for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to reset TS3 permission key for user %s" % request.user)
    return HttpResponseRedirect("/")
Exemplo n.º 12
0
def srp_fleet_add_view(request):
    logger.debug("srp_fleet_add_view called by user %s" % request.user)
    completed = False
    completed_srp_code = ""

    if request.method == 'POST':
        form = SrpFleetMainForm(request.POST)
        logger.debug("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(authinfo.main_char_id)

            srp_fleet_main = SrpFleetMain()
            srp_fleet_main.fleet_name = form.cleaned_data['fleet_name']
            srp_fleet_main.fleet_doctrine = form.cleaned_data['fleet_doctrine']
            srp_fleet_main.fleet_time = form.cleaned_data['fleet_time']
            srp_fleet_main.fleet_srp_code = random_string(8)
            srp_fleet_main.fleet_commander = character

            srp_fleet_main.save()

            completed = True
            completed_srp_code = srp_fleet_main.fleet_srp_code
            logger.info("Created SRP Fleet %s by user %s" % (srp_fleet_main.fleet_name, request.user))

    else:
        logger.debug("Returning blank SrpFleetMainForm")
        form = SrpFleetMainForm()

    render_items = {'form': form, "completed": completed, "completed_srp_code": completed_srp_code}

    return render_to_response('registered/srpfleetadd.html', render_items, context_instance=RequestContext(request))
Exemplo n.º 13
0
def add_timer_view(request):
    if request.method == 'POST':
        form = TimerForm(request.POST)

        if form.is_valid():
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            corporation = EveManager.get_corporation_info_by_id(character.corporation_id)

            # handle valid form
            timer = Timer()
            timer.name = form.cleaned_data['name']
            timer.system = form.cleaned_data['system']
            timer.planet_moon = form.cleaned_data['planet_moon']
            timer.structure = form.cleaned_data['structure']
            timer.fleet_type = form.cleaned_data['fleet_type']
            timer.eve_time = form.cleaned_data['eve_time']
            timer.important = form.cleaned_data['important']
            timer.eve_character = character
            timer.eve_corp = corporation
            timer.user = request.user
            timer.save()
            return HttpResponseRedirect("/timers/")
    else:
        form = TimerForm()

    render_items = {'form': form}

    return render_to_response('registered/addtimer.html', render_items, context_instance=RequestContext(request))
Exemplo n.º 14
0
def edit_signature(request, sigtracker_id):
    logger.debug("edit_optimer called by user %s for optimer id %s" % (request.user, sigtracker_id))
    sig = get_object_or_404(sigtracker, id=sigtracker_id)
    if request.method == 'POST':
        form = SignatureForm(request.POST)
        logger.debug("Received POST request containing update sigtracker form, is valid: %s" % form.is_valid())
        if form.is_valid():
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            sig.ident = form.cleaned_data['ident']
            sig.system = form.cleaned_data['system']
            sig.destination = form.cleaned_data['destination']
            sig.sigtype = form.cleaned_data['sigtype']
            sig.status = form.cleaned_data['status']
            sig.notes = form.cleaned_data['notes']
            sig.eve_character = character
            logger.info("User %s updating sigtracker id %s " % (request.user, sigtracker_id))
            sig.save()

        logger.debug("Detected no changes between sigtracker id %s and supplied form." % sigtracker_id)
        return HttpResponseRedirect("/sigtracker/")
    else:
        data = {
            'ident': sig.ident,
            'system': sig.system,
            'destination': sig.destination,
            'sigtype': sig.sigtype,
            'status': sig.status,
            'notes': sig.notes,
        }
        form = SignatureForm(initial= data)
    return render_to_response('registered/signatureupdate.html', {'form':form}, context_instance=RequestContext(request))
Exemplo n.º 15
0
def add_signature_view(request):
    logger.info("add_signature_view called by user %s" % request.user)
    if request.method == 'POST':
    	form = SignatureForm(request.POST)
	logger.info("Request type POST contains form valid: %s" % form.is_valid())
        if form.is_valid():
            #Get Current Time
            post_time = timezone.now()
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            # handle valid form
            sig = sigtracker()
            sig.ident = form.cleaned_data['ident']
            sig.system = form.cleaned_data['system']
            sig.destination = form.cleaned_data['destination']
            sig.sigtype = form.cleaned_data['sigtype']
            sig.status = form.cleaned_data['status']
            sig.notes = form.cleaned_data['notes']
            sig.create_time = post_time
            sig.eve_character = character
            sig.save()
            return HttpResponseRedirect("/sigtracker/")
    else:
        logger.info("Returning new SignatureForm")
        form = SignatureForm()

    render_items = {'form': form}

    return render_to_response('registered/addsignature.html', render_items, context_instance=RequestContext(request))
Exemplo n.º 16
0
def characters_view(request):
    logger.debug("characters_view called by user %s" % request.user)
    render_items = {
        "characters": EveManager.get_characters_by_owner_id(request.user.id),
        "authinfo": AuthServicesInfoManager.get_auth_service_info(request.user),
    }
    return render_to_response("registered/characters.html", render_items, context_instance=RequestContext(request))
Exemplo n.º 17
0
def set_jabber_password(request):
    logger.debug("set_jabber_password called by user %s" % request.user)
    error = None
    if request.method == "POST":
        logger.debug("Received POST request with form.")
        form = ServicePasswordForm(request.POST)
        logger.debug("Form is valid: %s" % form.is_valid())
        if form.is_valid():
            password = form.cleaned_data["password"]
            logger.debug("Form contains password of length %s" % len(password))
            authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
            result = OpenfireManager.update_user_pass(authinfo.jabber_username, password=password)
            if result != "":
                AuthServicesInfoManager.update_user_jabber_info(authinfo.jabber_username, result, request.user)
                logger.info("Succesfully reset forum password for user %s" % request.user)
                return HttpResponseRedirect("/services/")
            else:
                logger.error("Failed to install custom jabber password for user %s" % request.user)
                error = "Failed to install custom password."
        else:
            error = "Invalid password provided"
    else:
        logger.debug("Request is not type POST - providing empty form.")
        form = ServicePasswordForm()

    logger.debug("Rendering form for user %s" % request.user)
    context = {"form": form, "service": "Jabber", "error": error}
    return render_to_response("registered/service_password.html", context, context_instance=RequestContext(request))
Exemplo n.º 18
0
def services_view(request):
    logger.debug("services_view called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)

    return render_to_response(
        "registered/services.html", {"authinfo": authinfo}, context_instance=RequestContext(request)
    )
Exemplo n.º 19
0
def reset_teamspeak3_perm(request):
    logger.debug("reset_teamspeak3_perm 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("Deleting TS3 user for user %s" % request.user)
    Teamspeak3Manager.delete_user(authinfo.teamspeak3_uid)

    if check_if_user_has_permission(request.user, "blue_member"):
        logger.debug("Generating new permission key for blue user %s with main character %s" % (request.user, character))
        result = Teamspeak3Manager.generate_new_blue_permissionkey(authinfo.teamspeak3_uid, character.character_name,
                                                                   character.corporation_ticker)
    else:
        logger.debug("Generating new permission key for user %s with main character %s" % (request.user, character))
        result = Teamspeak3Manager.generate_new_permissionkey(authinfo.teamspeak3_uid, character.character_name,
                                                              character.corporation_ticker)

    # if blank we failed
    if result != "":
        AuthServicesInfoManager.update_user_teamspeak3_info(result[0], result[1], request.user)
        logger.debug("Updated authserviceinfo for user %s with TS3 credentials. Updating groups." % request.user)
        update_teamspeak3_groups.delay(request.user)
        logger.info("Successfully reset TS3 permission key for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to reset TS3 permission key for user %s" % request.user)
    return HttpResponseRedirect("/")
Exemplo n.º 20
0
def srp_fleet_add_view(request):
    completed = False
    completed_srp_code = ""

    if request.method == 'POST':
        form = SrpFleetMainForm(request.POST)

        if form.is_valid():
            authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(authinfo.main_char_id)

            srp_fleet_main = SrpFleetMain()
            srp_fleet_main.fleet_name = form.cleaned_data['fleet_name']
            srp_fleet_main.fleet_doctrine = form.cleaned_data['fleet_doctrine']
            srp_fleet_main.fleet_time = form.cleaned_data['fleet_time']
            srp_fleet_main.fleet_srp_code = random_string(8)
            srp_fleet_main.fleet_commander = character

            srp_fleet_main.save()

            completed = True
            completed_srp_code = srp_fleet_main.fleet_srp_code

    else:
        form = SrpFleetMainForm()

    render_items = {'form': form, "completed": completed, "completed_srp_code": completed_srp_code}

    return render_to_response('registered/srpfleetadd.html', render_items, context_instance=RequestContext(request))
Exemplo n.º 21
0
def srp_request_view(request, fleet_srp):
    completed = False
    no_srp_code = False
    srp_code = ""

    if SrpFleetMain.objects.filter(fleet_srp_code=fleet_srp).exists() is False:
        no_srp_code = True

    if request.method == 'POST':
        form = SrpFleetUserRequestForm(request.POST)

        if form.is_valid():
            authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
            character = EveManager.get_character_by_id(authinfo.main_char_id)
            srp_fleet_main = SrpFleetMain.objects.get(fleet_srp_code=fleet_srp)

            srp_request = SrpUserRequest()
            srp_request.killboard_link = form.cleaned_data['killboard_link']
            srp_request.additional_info = form.cleaned_data['additional_info']
            srp_request.character = character
            srp_request.srp_fleet_main = srp_fleet_main
            srp_request.save()

            completed = True

    else:
        form = SrpFleetUserRequestForm()

    render_items = {'form': form, "completed": completed, "no_srp_code": no_srp_code}

    return render_to_response('registered/srpfleetrequest.html', render_items, context_instance=RequestContext(request))
Exemplo n.º 22
0
def services_view(request):
    logger.debug("services_view called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)

    return render_to_response('registered/services.html',
                              {'authinfo': authinfo},
                              context_instance=RequestContext(request))
Exemplo n.º 23
0
def set_market_password(request):
    logger.debug("set_market_password called by user %s" % request.user)
    error = None
    if request.method == 'POST':
        logger.debug("Received POST request with form.")
        form = ServicePasswordForm(request.POST)
        logger.debug("Form is valid: %s" % form.is_valid())
        if form.is_valid():
            password = form.cleaned_data['password']
            logger.debug("Form contains password of length %s" % len(password))
            authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
            result = marketManager.update_custom_password(authinfo.market_username, password)
            if result != "":
                AuthServicesInfoManager.update_user_market_info(authinfo.market_username, result, request.user)
                logger.info("Succesfully reset market password for user %s" % request.user)
                return HttpResponseRedirect("/services/")
            else:
                logger.error("Failed to install custom market password for user %s" % request.user)
                error = "Failed to install custom password."
        else:
            error = "Invalid password provided"
    else:
        logger.debug("Request is not type POST - providing empty form.")
        form = ServicePasswordForm()

    logger.debug("Rendering form for user %s" % request.user)
    context = {'form': form, 'service': 'Market'}
    return render_to_response('registered/service_password.html', context, context_instance=RequestContext(request))
Exemplo n.º 24
0
def main_character_change(request, char_id):
    if EveManager.check_if_character_owned_by_user(char_id, request.user):
        previousmainid = AuthServicesInfoManager.get_auth_service_info(request.user).main_char_id
        AuthServicesInfoManager.update_main_char_Id(char_id, request.user)
        # Check if character is in the alliance
        character_info = EveManager.get_character_by_id(char_id)
        corporation_info = EveManager.get_corporation_info_by_id(character_info.corporation_id)

        if EveManager.get_charater_alliance_id_by_id(char_id) == settings.ALLIANCE_ID:
            add_member_permission(request.user, 'alliance_member')
            add_user_to_group(request.user, settings.DEFAULT_ALLIANCE_GROUP)
            add_user_to_group(request.user,
                              generate_corp_group_name(EveManager.get_character_by_id(char_id).corporation_name))

        elif corporation_info != None:
            if corporation_info.is_blue:
                add_member_permission(request.user, 'blue_member')
                add_user_to_group(request.user, settings.DEFAULT_BLUE_GROUP)
                AuthServicesInfoManager.update_is_blue(True, request.user)
            else:
                if check_if_user_has_permission(request.user, 'alliance_member'):
                    disable_alliance_member(request.user, previousmainid)

                if check_if_user_has_permission(request.user, 'blue_member'):
                    disable_blue_member(request.user)
        else:
            # TODO: disable serivces
            if check_if_user_has_permission(request.user, 'alliance_member'):
                disable_alliance_member(request.user, previousmainid)

            if check_if_user_has_permission(request.user, 'blue_member'):
                disable_blue_member(request.user)

        return HttpResponseRedirect("/characters")
    return HttpResponseRedirect("/characters")
Exemplo n.º 25
0
def add_signature_view(request):
    logger.info("add_signature_view called by user %s" % request.user)
    if request.method == 'POST':
        form = SignatureForm(request.POST)
        logger.info("Request type POST contains form valid: %s" %
                    form.is_valid())
        if form.is_valid():
            #Get Current Time
            post_time = timezone.now()
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(
                request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            # handle valid form
            sig = sigtracker()
            sig.ident = form.cleaned_data['ident']
            sig.system = form.cleaned_data['system']
            sig.destination = form.cleaned_data['destination']
            sig.sigtype = form.cleaned_data['sigtype']
            sig.status = form.cleaned_data['status']
            sig.notes = form.cleaned_data['notes']
            sig.create_time = post_time
            sig.eve_character = character
            sig.save()
            return HttpResponseRedirect("/sigtracker/")
    else:
        logger.info("Returning new SignatureForm")
        form = SignatureForm()

    render_items = {'form': form}

    return render_to_response('registered/addsignature.html',
                              render_items,
                              context_instance=RequestContext(request))
Exemplo n.º 26
0
def add_timer_view(request):
    if request.method == 'POST':
        form = TimerForm(request.POST)

        if form.is_valid():
            # Get character
            auth_info = AuthServicesInfoManager.get_auth_service_info(
                request.user)
            character = EveManager.get_character_by_id(auth_info.main_char_id)
            corporation = EveManager.get_corporation_info_by_id(
                character.corporation_id)

            # handle valid form
            timer = Timer()
            timer.name = form.cleaned_data['name']
            timer.system = form.cleaned_data['system']
            timer.planet_moon = form.cleaned_data['planet_moon']
            timer.structure = form.cleaned_data['structure']
            timer.fleet_type = form.cleaned_data['fleet_type']
            timer.eve_time = form.cleaned_data['eve_time']
            timer.important = form.cleaned_data['important']
            timer.eve_character = character
            timer.eve_corp = corporation
            timer.user = request.user
            timer.save()
            return HttpResponseRedirect("/timers/")
    else:
        form = TimerForm()

    render_items = {'form': form}

    return render_to_response('registered/addtimer.html',
                              render_items,
                              context_instance=RequestContext(request))
Exemplo n.º 27
0
def reset_discord(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = DiscordManager.delete_user(authinfo.discord_uid)
    if result:
        AuthServicesInfoManager.update_user_discord_info("",request.user)
        return HttpResponseRedirect("/activate_discord/")
    return HttpResponseRedirect("/services/")
Exemplo n.º 28
0
def reset_mumble_password(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = MumbleManager.update_user_password(authinfo.mumble_username)
    # if blank we failed
    if result != "":
        AuthServicesInfoManager.update_user_mumble_info(authinfo.mumble_username, result, request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/")
Exemplo n.º 29
0
def reset_jabber_password(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = OpenfireManager.update_user_pass(authinfo.jabber_username)
    # If our username is blank means we failed
    if result != "":
        AuthServicesInfoManager.update_user_jabber_info(authinfo.jabber_username, result, request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 30
0
def reset_forum_password(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = Phpbb3Manager.update_user_password(authinfo.forum_username)
    # false we failed
    if result != "":
        AuthServicesInfoManager.update_user_forum_info(authinfo.forum_username, result, request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 31
0
 def main_character(self, obj):
     auth = AuthServicesInfoManager.get_auth_service_info(obj.user)
     if auth and auth.main_char_id:
         try:
             return EveCharacter.objects.get(character_id=auth.main_char_id)
         except EveCharacter.DoesNotExist:
             pass
     return None
Exemplo n.º 32
0
 def main_character(self, obj):
     auth = AuthServicesInfoManager.get_auth_service_info(obj.user)
     if auth and auth.main_char_id:
         try:
             return EveCharacter.objects.get(character_id=auth.main_char_id)
         except EveCharacter.DoesNotExist:
             pass
     return None
Exemplo n.º 33
0
def deactivate_jabber(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = JabberManager.delete_user(authinfo.jabber_username)
    # If our username is blank means we failed
    if result:
        AuthServicesInfoManager.update_user_jabber_info("", "", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 34
0
def deactivate_discord(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = DiscordManager.delete_user(authinfo.discord_uid)
    if result:
        remove_all_syncgroups_for_service(request.user, "discord")
        AuthServicesInfoManager.update_user_discord_info("", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 35
0
def deactivate_blue_mumble(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = MumbleManager.delete_user(authinfo.mumble_username)
    # if false we failed
    if result:
        AuthServicesInfoManager.update_user_mumble_info("", "", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/")
Exemplo n.º 36
0
def deactivate_forum(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = ForumManager.disable_user(authinfo.forum_username)
    # false we failed
    if result:
        AuthServicesInfoManager.update_user_forum_info("", "", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 37
0
def dashboard_view(request):
    render_items = {
        'characters': EveManager.get_characters_by_owner_id(request.user.id),
        'authinfo': AuthServicesInfoManager.get_auth_service_info(request.user)
    }
    return render_to_response('registered/dashboard.html',
                              render_items,
                              context_instance=RequestContext(request))
Exemplo n.º 38
0
def deactivate_jabber(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = OpenfireManager.delete_user(authinfo.jabber_username)
    remove_all_syncgroups_for_service(request.user, "openfire")
    # If our username is blank means we failed
    if result:
        AuthServicesInfoManager.update_user_jabber_info("", "", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 39
0
def reset_jabber_password(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = OpenfireManager.update_user_pass(authinfo.jabber_username)
    # If our username is blank means we failed
    if result != "":
        AuthServicesInfoManager.update_user_jabber_info(
            authinfo.jabber_username, result, request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 40
0
def deactivate_mumble(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = MumbleManager.delete_user(authinfo.mumble_username)
    remove_all_syncgroups_for_service(request.user, "mumble")
    # if false we failed
    if result:
        AuthServicesInfoManager.update_user_mumble_info("", "", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/")
Exemplo n.º 41
0
def deactivate_ipboard_forum(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = IPBoardManager.disable_user(authinfo.ipboard_username)
    remove_all_syncgroups_for_service(request.user, "ipboard")
    # false we failed
    if result:
        AuthServicesInfoManager.update_user_ipboard_info("", "", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 42
0
def deactivate_ipboard_forum(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = IPBoardManager.disable_user(authinfo.ipboard_username)
    remove_all_syncgroups_for_service(request.user, "ipboard")
    # false we failed
    if result:
        AuthServicesInfoManager.update_user_ipboard_info("", "", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 43
0
def deactivate_services(user):
    change = False
    logger.debug("Deactivating services for user %s" % user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(user)
    if authinfo.mumble_username and authinfo.mumble_username != "":
        logger.debug("User %s has mumble account %s. Deleting." %
                     (user, authinfo.mumble_username))
        MumbleManager.delete_user(authinfo.mumble_username)
        AuthServicesInfoManager.update_user_mumble_info("", "", user)
        change = True
    if authinfo.jabber_username and authinfo.jabber_username != "":
        logger.debug("User %s has jabber account %s. Deleting." %
                     (user, authinfo.jabber_username))
        OpenfireManager.delete_user(authinfo.jabber_username)
        AuthServicesInfoManager.update_user_jabber_info("", "", user)
        change = True
    if authinfo.forum_username and authinfo.forum_username != "":
        logger.debug("User %s has forum account %s. Deleting." %
                     (user, authinfo.forum_username))
        Phpbb3Manager.disable_user(authinfo.forum_username)
        AuthServicesInfoManager.update_user_forum_info("", "", user)
        change = True
    if authinfo.ipboard_username and authinfo.ipboard_username != "":
        logger.debug("User %s has ipboard account %s. Deleting." %
                     (user, authinfo.ipboard_username))
        IPBoardManager.disable_user(authinfo.ipboard_username)
        AuthServicesInfoManager.update_user_forum_info("", "", user)
        change = True
    if authinfo.teamspeak3_uid and authinfo.teamspeak3_uid != "":
        logger.debug("User %s has mumble account %s. Deleting." %
                     (user, authinfo.teamspeak3_uid))
        Teamspeak3Manager.delete_user(authinfo.teamspeak3_uid)
        AuthServicesInfoManager.update_user_teamspeak3_info("", "", user)
        change = True
    if authinfo.discord_uid and authinfo.discord_uid != "":
        logger.debug("User %s has discord account %s. Deleting." %
                     (user, authinfo.discord_uid))
        DiscordOAuthManager.delete_user(authinfo.discord_uid)
        AuthServicesInfoManager.update_user_discord_info("", user)
        change = True
    if authinfo.xenforo_username and authinfo.xenforo_password != "":
        logger.debug("User %s has a XenForo account %s. Deleting." %
                     (user, authinfo.xenforo_username))
        XenForoManager.disable_user(authinfo.xenforo_username)
        AuthServicesInfoManager.update_user_xenforo_info("", "", user)
        change = True
    if authinfo.market_username and authinfo.market_username != "":
        logger.debug("User %s has a Market account %s. Deleting." %
                     (user, authinfo.market_username))
        marketManager.disable_user(authinfo.market_username)
        AuthServicesInfoManager.update_user_market_info("", "", user)
        change = True
    if change:
        notify(user,
               "Services Disabled",
               message="Your services accounts have been disabled.",
               level="danger")
Exemplo n.º 44
0
def deactivate_jabber(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = OpenfireManager.delete_user(authinfo.jabber_username)
    remove_all_syncgroups_for_service(request.user, "openfire")
    # If our username is blank means we failed
    if result:
        AuthServicesInfoManager.update_user_jabber_info("", "", request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 45
0
def reset_forum_password(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = Phpbb3Manager.update_user_password(authinfo.forum_username)
    # false we failed
    if result != "":
        AuthServicesInfoManager.update_user_forum_info(authinfo.forum_username,
                                                       result, request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 46
0
def characters_view(request):
    logger.debug("characters_view called by user %s" % request.user)
    render_items = {
        'characters': EveManager.get_characters_by_owner_id(request.user.id),
        'authinfo': AuthServicesInfoManager.get_auth_service_info(request.user)
    }
    return render_to_response('registered/characters.html',
                              render_items,
                              context_instance=RequestContext(request))
Exemplo n.º 47
0
def reset_ipboard_password(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = IPBoardManager.update_user_password(authinfo.ipboard_username,
                                                 request.user.email)
    if result != "":
        AuthServicesInfoManager.update_user_ipboard_info(
            authinfo.ipboard_username, result, request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 48
0
def deactivate_ips4(request):
    logger.debug("deactivate_ips4 called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = Ips4Manager.delete_user(authinfo.ips4_id)
    if result != "":
        AuthServicesInfoManager.update_user_ips4_info("", "", "", request.user)
        logger.info("Succesfully deactivated IPS4 for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccesful attempt to deactivate IPS4 for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 49
0
def reset_discord(request):
    logger.debug("reset_discord called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = DiscordManager.delete_user(authinfo.discord_uid)
    if result:
        AuthServicesInfoManager.update_user_discord_info("",request.user)
        logger.info("Succesfully deleted discord user for user %s - forwarding to discord activation." % request.user)
        return HttpResponseRedirect("/activate_discord/")
    logger.error("Unsuccessful attempt to reset discord for user %s" % request.user)
    return HttpResponseRedirect("/services/")
Exemplo n.º 50
0
def reset_ipboard_password(request):
    logger.debug("reset_ipboard_password called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = IPBoardManager.update_user_password(authinfo.ipboard_username, request.user.email)
    if result != "":
        AuthServicesInfoManager.update_user_ipboard_info(authinfo.ipboard_username, result, request.user)
        logger.info("Succesfully reset ipboard password for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccesful attempt to reset ipboard password for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 51
0
def reset_mumble_password(request):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = MumbleManager.update_user_password(authinfo.mumble_username)

    # if blank we failed
    if result != "":
        AuthServicesInfoManager.update_user_mumble_info(
            authinfo.mumble_username, result, request.user)
        return HttpResponseRedirect("/services/")
    return HttpResponseRedirect("/")
Exemplo n.º 52
0
def reset_discord(request):
    logger.debug("reset_discord called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = DiscordManager.delete_user(authinfo.discord_uid)
    if result:
        AuthServicesInfoManager.update_user_discord_info("",request.user)
        logger.info("Succesfully deleted discord user for user %s - forwarding to discord activation." % request.user)
        return HttpResponseRedirect("/activate_discord/")
    logger.error("Unsuccessful attempt to reset discord for user %s" % request.user)
    return HttpResponseRedirect("/services/")
Exemplo n.º 53
0
def reset_ipboard_password(request):
    logger.debug("reset_ipboard_password called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = IPBoardManager.update_user_password(authinfo.ipboard_username, request.user.email)
    if result != "":
        AuthServicesInfoManager.update_user_ipboard_info(authinfo.ipboard_username, result, request.user)
        logger.info("Succesfully reset ipboard password for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccesful attempt to reset ipboard password for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 54
0
def reset_jabber_password(request):
    logger.debug("reset_jabber_password called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = OpenfireManager.update_user_pass(authinfo.jabber_username)
    # If our username is blank means we failed
    if result != "":
        AuthServicesInfoManager.update_user_jabber_info(authinfo.jabber_username, result, request.user)
        logger.info("Succesfully reset jabber password for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to reset jabber for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 55
0
def deactivate_market(request):
    logger.debug("deactivate_market called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = marketManager.disable_user(authinfo.market_username)
    # false we failed
    if result:
        AuthServicesInfoManager.update_user_market_info("", "", request.user)
        logger.info("Succesfully deactivated market for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccesful attempt to activate market for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 56
0
def reset_market_password(request):
    logger.debug("reset_market_password called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = marketManager.update_user_password(authinfo.market_username)
    # false we failed
    if result != "":
        AuthServicesInfoManager.update_user_market_info(authinfo.market_username, result, request.user)
        logger.info("Succesfully reset market password for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to reset market password for user %s" % request.user)
    return HttpResponseRedirect("/dashboard")
Exemplo n.º 57
0
def deactivate_mumble(request):
    logger.debug("deactivate_mumble called by user %s" % request.user)
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    result = MumbleManager.delete_user(authinfo.mumble_username)
    # if false we failed
    if result:
        AuthServicesInfoManager.update_user_mumble_info("", "", request.user)
        logger.info("Succesfully deactivated mumble for user %s" % request.user)
        return HttpResponseRedirect("/services/")
    logger.error("Unsuccessful attempt to deactivate mumble for user %s" % request.user)
    return HttpResponseRedirect("/")