Ejemplo n.º 1
0
 def delete_user(self, user, notify_user=False):
     logging.debug("Deleting user %s %s account" % (user, self.name))
     if MumbleManager.delete_user(user):
         if notify_user:
             notify(user, 'Mumble Account Disabled', level='danger')
         return True
     return False
Ejemplo n.º 2
0
def hr_application_mark_in_progress(request, app_id):
    logger.debug(
        "hr_application_mark_in_progress called by user %s for app id %s" %
        (request.user, app_id))
    app = get_object_or_404(Application, pk=app_id)
    if not app.reviewer:
        logger.info("User %s marking %s in progress" % (request.user, app))
        auth_info = AuthServicesInfo.objects.get(user=request.user)
        try:
            character = EveCharacter.objects.get(
                character_id=auth_info.main_char_id)
        except EveCharacter.DoesNotExist:
            logger.warn("User %s marking %s in review has no main character" %
                        (request.user, app))
            character = None
        app.reviewer = request.user
        app.reviewer_character = character
        app.save()
        notify(app.user,
               "Application In Progress",
               message="Your application to %s is being reviewed by %s" %
               (app.form.corp, app.reviewer_str))
    else:
        logger.warn(
            "User %s unable to mark %s in progress: already being reviewed by %s"
            % (request.user, app, app.reviewer))
    return redirect("auth_hrapplication_view", app_id)
Ejemplo n.º 3
0
def run_api_refresh():
    users = User.objects.all()
    logger.debug("Running api refresh on %s users." % len(users))
    for user in users:
        # Check if the api server is online
        logger.debug("Running api refresh for user %s" % user)
        if EveApiManager.check_if_api_server_online():
            api_key_pairs = EveManager.get_api_key_pairs(user.id)
            logger.debug("User %s has api key pairs %s" % (user, api_key_pairs))
            if api_key_pairs:
                authserviceinfo, c = AuthServicesInfo.objects.get_or_create(user=user)
                logger.debug("User %s has api keys. Proceeding to refresh." % user)
                for api_key_pair in api_key_pairs:
                    try:
                        refresh_api(api_key_pair)
                    except evelink.api.APIError as e:
                        if int(e.code) >= 500:
                            logger.error("EVE API servers encountered error %s updating %s" % (e.code, api_key_pair))
                        elif int(e.code) == 221:
                            logger.warn("API server hiccup %s while updating %s" % (e.code, api_key_pair))
                        else:
                            logger.info("API key %s failed update with error code %s" % (api_key_pair.api_id, e.code))
                            EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
                            EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
                            notify(user, "API Key Deleted", message="Your API key ID %s failed validation with code %s. It and its associated characters have been deleted." % (api_key_pair.api_id, e.code), level="danger")
                # Check our main character
                if EveCharacter.objects.filter(character_id=authserviceinfo.main_char_id).exists() is False:
                    logger.info("User %s main character id %s missing model. Clearning main character." % (user, authserviceinfo.main_char_id))
                    authserviceinfo.main_char_id = ''
                    authserviceinfo.save()
                    notify(user, "Main Character Reset", message="Your specified main character no longer has a model.\nThis could be the result of an invalid API\nYour main character ID has been reset.", level="warn")
        set_state(user)
Ejemplo n.º 4
0
def hr_application_remove(request, app_id):
    logger.debug("hr_application_remove called by user %s for app id %s" % (request.user, app_id))
    app = get_object_or_404(Application, pk=app_id)
    logger.info("User %s deleting %s" % (request.user, app))
    app.delete()
    notify(app.user, "Application Deleted", message="Your application to %s was deleted." % app.form.corp)
    return redirect('auth_hrapplications_view')
Ejemplo n.º 5
0
    def emit(self, record):
        from django.contrib.auth.models import User, Permission
        from django.db.models import Q
        from notifications import notify
        from notifications.models import Notification

        try:
            perm = Permission.objects.get(codename="logging_notifications")

            message = record.getMessage()
            if record.exc_text:
                message += "\n\n"
                message = message + record.exc_text

            users = User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) | Q(is_superuser=True)).distinct()

            for user in users:
                notify(
                    user,
                    "%s [%s:%s]" % (record.levelname, record.funcName, record.lineno),
                    level = str([item[0] for item in Notification.LEVEL_CHOICES if item[1] == record.levelname][0]),
                    message = message
                )
        except Permission.DoesNotExist:
            pass
Ejemplo n.º 6
0
def srp_request_approve(request, srp_request_id):
    logger.debug("srp_request_approve called by user %s for srp request id %s" % (request.user, srp_request_id))
    stored_fleet_view = None

    if SrpUserRequest.objects.filter(id=srp_request_id).exists():
        srpuserrequest = SrpUserRequest.objects.get(id=srp_request_id)
        stored_fleet_view = srpuserrequest.srp_fleet_main.id
        srpuserrequest.srp_status = "Approved"
        if srpuserrequest.srp_total_amount == 0:
            srpuserrequest.srp_total_amount = srpuserrequest.kb_total_loss
        srpuserrequest.save()
        logger.info("Approved SRP request id %s for character %s by user %s" % (
            srp_request_id, srpuserrequest.character, request.user))
        messages.success(request, _('Approved SRP request from %(character)s for their %(ship)s.') % {
            "character": srpuserrequest.character, "ship": srpuserrequest.srp_ship_name})
        notify(
            srpuserrequest.character.user,
            'SRP Request Approved',
            level='success',
            message='Your SRP request for a %s lost during %s has been approved for %s ISK.' % (
                srpuserrequest.srp_ship_name, srpuserrequest.srp_fleet_main.fleet_name, srpuserrequest.srp_total_amount)
        )
    if stored_fleet_view is None:
        logger.error("Unable to approve srp request id %s on behalf of user %s - request matching id not found." % (
            srp_request_id, request.user))
        messages.error(request, _('Unable to locate SRP request with ID %(requestid)s') % {"requestid": srp_request_id})
        return redirect("auth_srp_management_view")
    else:
        return redirect("auth_srp_fleet_view", stored_fleet_view)
Ejemplo n.º 7
0
def group_accept_request(request, group_request_id):
    logger.debug(
        "group_accept_request called by user %s for grouprequest id %s" %
        (request.user, group_request_id))
    try:
        group_request = GroupRequest.objects.get(id=group_request_id)
        group, created = Group.objects.get_or_create(
            name=group_request.group.name)
        group_request.user.groups.add(group)
        group_request.user.save()
        group_request.delete()
        logger.info(
            "User %s accepted group request from user %s to group %s" %
            (request.user, group_request.user, group_request.group.name))
        notify(group_request.user,
               "Group Application Accepted",
               level="success",
               message="Your application to %s has been accepted." %
               group_request.group)
    except:
        logger.exception(
            "Unhandled exception occured while user %s attempting to accept grouprequest id %s."
            % (request.user, group_request_id))
        pass

    return HttpResponseRedirect("/group/management/")
Ejemplo n.º 8
0
 def cb(data):
     print data
     notify(
         'success',
         'Added',
         u'Track <b>{}</b> added to your audios.'.format(title_string),
         timeout=5000)
Ejemplo n.º 9
0
def group_reject_request(request, group_request_id):
    logger.debug(
        "group_reject_request called by user %s for group request id %s" %
        (request.user, group_request_id))
    try:
        group_request = GroupRequest.objects.get(id=group_request_id)

        if group_request:
            logger.info(
                "User %s rejected group request from user %s to group %s" %
                (request.user, group_request.user, group_request.group.name))
            group_request.delete()
            notify(group_request.user,
                   "Group Application Rejected",
                   level="danger",
                   message="Your application to %s has been rejected." %
                   group_request.group)
            messages.success(
                request, 'Rejected application from %s to %s.' %
                (group_request.main_char, group_request.group))
    except:
        messages.error(
            request,
            'An unhandled error occured while processing the application from %s to %s.'
            % (group_request.main_char, group_request.group))
        logger.exception(
            "Unhandled exception occured while user %s attempting to reject group request id %s"
            % (request.user, group_request_id))
        pass

    return redirect("auth_group_management")
Ejemplo n.º 10
0
def group_accept_request(request, group_request_id):
    logger.debug(
        "group_accept_request called by user %s for grouprequest id %s" %
        (request.user, group_request_id))
    try:
        group_request = GroupRequest.objects.get(id=group_request_id)
        group, created = Group.objects.get_or_create(
            name=group_request.group.name)
        group_request.user.groups.add(group)
        group_request.user.save()
        group_request.delete()
        logger.info(
            "User %s accepted group request from user %s to group %s" %
            (request.user, group_request.user, group_request.group.name))
        notify(group_request.user,
               "Group Application Accepted",
               level="success",
               message="Your application to %s has been accepted." %
               group_request.group)
        messages.success(
            request, 'Accepted application from %s to %s.' %
            (group_request.main_char, group_request.group))
    except:
        messages.error(
            request,
            'An unhandled error occurred while processing the application from %s to %s.'
            % (group_request.main_char, group_request.group))
        logger.exception(
            "Unhandled exception occurred while user %s attempting to accept grouprequest id %s."
            % (request.user, group_request_id))
        pass

    return redirect("auth_group_management")
Ejemplo n.º 11
0
def srp_request_reject(request, srp_request_id):
    logger.debug("srp_request_reject called by user %s for srp request id %s" %
                 (request.user, srp_request_id))
    stored_fleet_view = None

    if SrpUserRequest.objects.filter(id=srp_request_id).exists():
        srpuserrequest = SrpUserRequest.objects.get(id=srp_request_id)
        stored_fleet_view = srpuserrequest.srp_fleet_main.id
        srpuserrequest.srp_status = "Rejected"
        srpuserrequest.save()
        logger.info("SRP request id %s for character %s rejected by %s" %
                    (srp_request_id, srpuserrequest.character, request.user))
        messages.success(
            request, 'Rejected SRP request from %s for their %s.' %
            (srpuserrequest.character, srpuserrequest.srp_ship_name))
        notify(srpuserrequest.character.user,
               'SRP Request Rejected',
               level='danger',
               message=
               'Your SRP request for a %s lost during %s has been rejected.' %
               (srpuserrequest.srp_ship_name,
                srpuserrequest.srp_fleet_main.fleet_name))

    if stored_fleet_view is None:
        logger.error(
            "Unable to reject SRP request id %s on behalf of user %s - request matching id not found."
            % (srp_request_id, request.user))
        messages.error(
            request,
            'Unable to locate SRP request with ID %s' % srp_request_id)
        return redirect("auth_srp_management_view")
    else:
        return redirect("auth_srp_fleet_view", stored_fleet_view)
Ejemplo n.º 12
0
def run_resource(resourceid):
    resource = Resource.query.filter_by(identifier=resourceid).first()

    if not resource.active:
        # Exit test of resource if it's not active
        return

    # Get the status of the last run,
    # assume success if there is none
    last_run_success = True
    last_run = resource.last_run
    if last_run:
        last_run_success = last_run.success

    # Run test
    result = run_test_resource(resource)

    run1 = Run(resource, result, datetime.utcnow())

    DB.session.add(run1)

    # commit or rollback each run to avoid long-lived transactions
    # see https://github.com/geopython/GeoHealthCheck/issues/14
    db_commit()

    if APP.config['GHC_NOTIFICATIONS']:
        # Attempt notification
        try:
            notify(APP.config, resource, run1, last_run_success)
        except Exception as err:
            # Don't bail out on failure in order to commit the Run
            msg = str(err)
            logging.warn('error notifying: %s' % msg)
    if not __name__ == '__main__':
        DB.session.remove()
Ejemplo n.º 13
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user) and SeatManager.delete_user(user.seat.username):
         user.seat.delete()
         logger.info("Successfully deactivated SeAT for user %s" % user)
         if notify_user:
             notify(user, 'SeAT Account Disabled', level='danger')
         return True
     return False
Ejemplo n.º 14
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user):
         if IPBoardManager.disable_user(user.ipboard.username):
             user.ipboard.delete()
             if notify_user:
                 notify(user, 'IPBoard Account Disabled', level='danger')
             return True
     return False
Ejemplo n.º 15
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user):
         logger.debug("User %s has forum account %s. Deleting." % (user, user.phpbb3.username))
         if Phpbb3Manager.disable_user(user.phpbb3.username):
             user.phpbb3.delete()
             if notify_user:
                 notify(user, 'Forum Account Disabled', level='danger')
             return True
     return False
Ejemplo n.º 16
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user):
         logger.debug("User %s has jabber account %s. Deleting." % (user, user.openfire.username))
         OpenfireManager.delete_user(user.openfire.username)
         user.openfire.delete()
         if notify_user:
             notify(user, 'Jabber Account Disabled', level='danger')
         return True
     return False
Ejemplo n.º 17
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user):
         logger.debug("User %s has a Market account %s. Deleting." % (user, user.market.username))
         if MarketManager.disable_user(user.market.username):
             user.market.delete()
             if notify_user:
                 notify(user, 'Alliance Market Account Disabled', level='danger')
             return True
     return False
Ejemplo n.º 18
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user):
         logger.debug("User %s has discord account %s. Deleting." % (user, user.discord.uid))
         if DiscordOAuthManager.delete_user(user.discord.uid):
             user.discord.delete()
             if notify_user:
                 notify(user, 'Discord Account Disabled', level='danger')
             return True
     return False
Ejemplo n.º 19
0
def deactivate_services(user):
    change = False
    logger.debug("Deactivating services for user %s" % user)
    authinfo = AuthServicesInfo.objects.get_or_create(user=user)[0]
    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_ipboard_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 authinfo.discourse_enabled:
        logger.debug("User %s has a Discourse account. Disabling login." % user)
        DiscourseManager.disable_user(user)
        authinfo.discourse_enabled = False
        authinfo.save()
        change = True
    if authinfo.smf_username and authinfo.smf_username != "":
        logger.debug("User %s has a SMF account %s. Deleting." % (user, authinfo.smf_username))
        smfManager.disable_user(authinfo.smf_username)
        AuthServicesInfoManager.update_user_smf_info("", user)
        change = True
    if change:
        notify(user, "Services Disabled", message="Your services accounts have been disabled.", level="danger")
Ejemplo n.º 20
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user):
         logger.debug("User %s has a XenForo account %s. Deleting." %
                      (user, user.xenforo.username))
         if XenForoManager.disable_user(user.xenforo.username) == 200:
             user.xenforo.delete()
             if notify_user:
                 notify(user, 'XenForo Account Disabled', level='danger')
             return True
     return False
Ejemplo n.º 21
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user):
         logger.debug("User %s has a SMF account %s. Deleting." %
                      (user, user.smf.username))
         SmfManager.disable_user(user.smf.username)
         user.smf.delete()
         if notify_user:
             notify(user, "SMF Account Disabled", level='danger')
         return True
     return False
Ejemplo n.º 22
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user) and user.discourse.enabled:
         logger.debug("User %s has a Discourse account. Disabling login." %
                      user)
         if DiscourseManager.disable_user(user):
             user.discourse.delete()
             if notify_user:
                 notify(user, 'Discourse Account Disabled', level='danger')
             return True
     return False
Ejemplo n.º 23
0
 def delete_user(cls, user, notify_user=False):
     if cls.has_account(user):
         logger.debug("User %s has TS3 account %s. Deleting." %
                      (user, user.teamspeak3.uid))
         if Teamspeak3Manager.delete_user(user.teamspeak3.uid):
             user.teamspeak3.delete()
             if notify_user:
                 notify(user, 'TeamSpeak3 Account Disabled', level='danger')
             return True
     return False
def check_temp_ph_parameters(measurement, tank_name, influx_table, measurement_name):
    """Check that  pH and Temperature tank parameters are within limits. Alerts us if they are not."""
    log.debug("check_temp_ph_parameters() called")
    current_measurement = read_influx_database(influx_table, tank_name)
    log.debug(f"The current {measurement_name} of {tank_name} is {current_measurement:1.2f}")
    system_measurement_low = getattr(system_info, measurement + '_low')
    system_measurement_high = getattr(system_info, measurement + '_high')
    if current_measurement < system_measurement_low:
        measurement_alert_time = getattr(system_info, measurement + '_alert_time')
        alert_sent = read_mysql_database(measurement, "alert_sent")
        if alert_sent:
            resend_alert = last_alert_time(measurement, measurement_alert_time)
            if resend_alert:
                notify(measurement, "Fish Tank Controller", f"Your {tank_name} tank is still reporting a LOW {measurement_name} of {current_measurement}!")
                update_mysql_database(measurement, "last_alert_sent_time", current_timestamp)
                log.debug(f"{measurement_name} Alert Notification RESENT at {current_military_time}.")
            log.debug(f"Tank {measurement_name} is LOW!")
        else:
            notify(measurement, "Fish Tank Controller", f"Your {tank_name} tank has reported a LOW {measurement_name} of {current_measurement}!")
            update_mysql_database(measurement, "last_alert_sent_time", current_timestamp)
            update_mysql_database(measurement, "alert_sent", True)
            log.debug(f"{measurement_name} Alert Notification sent at {current_military_time}.")
            log.warning(f"{tank_name} has reported a LOW {measurement_name}!")
            update_mysql_database("led_status", measurement + '_low', True)
            update_mysql_database(measurement, "ok", False)
    elif current_measurement > system_measurement_high:
        measurement_alert_time = getattr(system_info, measurement + '_alert_time')
        alert_sent = read_mysql_database(measurement, "alert_sent")
        if alert_sent:
            resend_alert = last_alert_time(measurement, measurement_alert_time)
            if resend_alert:
                notify(measurement, "Fish Tank Controller",
                       f"Your {tank_name} tank is still reported a HIGH {measurement_name} of {current_measurement}!")
                update_mysql_database(measurement, "last_alert_sent_time", current_timestamp)
                log.debug(f"{measurement_name} Alert Notification RESENT at {current_military_time}.")
            log.debug(f"Tank {measurement_name} is HIGH!")
        else:
            notify(measurement, "Fish Tank Controller", f"Your {tank_name} tank has reported a HIGH {measurement_name} of {current_measurement}!")
            update_mysql_database(measurement, "last_alert_sent_time", current_timestamp)
            update_mysql_database(measurement, "alert_sent", True)
            log.debug(f"{measurement_name} Alert Notification sent at {current_military_time}.")
            log.warning(f"{tank_name} has reported a HIGH {measurement_name}!")
            update_mysql_database("led_status", measurement + '_high', True)
            update_mysql_database(measurement, "ok", False)
    else:
        ok = read_mysql_database(measurement, "ok")
        if not ok:
            update_mysql_database("led_status", measurement + '_high', False)
            update_mysql_database("led_status", measurement + '_low', False)
            update_mysql_database(measurement, "ok", True)
            update_mysql_database(measurement, "alert_sent", False)
            log.debug(f"{tank_name} has reported you are back to a NORMAL {measurement_name}!")
            notify(measurement, "Fish Tank Controller",
                   f"Your {tank_name} tank {measurement_name} is back to NORMAL, now reporting {current_measurement}!")
        log.debug(f"{tank_name} has reported a NORMAL {measurement_name}!")
Ejemplo n.º 25
0
def evaluate():
    for i in change:
        amount = 0.03 * change[i]['Volume']
        #if(amount > 10):
        #   amount = 10
        if ((change[i]['Change'] >= amount and change[i]['Name'][0] == 'B'
             and change[i]['Volume'] >= 20)):
            notify(change[i], 3)
        elif (change[i]['Change'] <= -0.1 * change[i]['Volume']
              and change[i]['Name'][0] == 'B' and change[i]['Volume'] >= 40):
            notify(change[i], 2)
Ejemplo n.º 26
0
def hr_application_reject(request, app_id):
    logger.debug("hr_application_reject called by user %s for app id %s" % (request.user, app_id))
    app = get_object_or_404(Application, pk=app_id)
    if request.user.is_superuser or request.user == app.reviewer:
        logger.info("User %s rejecting %s" % (request.user, app))
        app.approved = False
        app.save()
        notify(app.user, "Application Rejected", message="Your application to %s has been rejected." % app.form.corp,
               level="danger")
    else:
        logger.warn("User %s not authorized to reject %s" % (request.user, app))
    return redirect('auth_hrapplications_view')
Ejemplo n.º 27
0
def set_state(user):
    if user.is_active:
        state = determine_membership_by_user(user)
    else:
        state = NONE_STATE
    logger.debug("Assigning user %s to state %s" % (user, state))
    auth = AuthServicesInfo.objects.get_or_create(user=user)[0]
    if auth.state != state:
        auth.state = state
        auth.save()
        notify(user,
               "Membership State Change",
               message="You membership state has been changed to %s" % state)
Ejemplo n.º 28
0
def srp_request_view(request, fleet_srp):
    logger.debug("srp_request_view called by user %s for fleet srp code %s" % (request.user, 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
        logger.error("Unable to locate SRP Fleet using code %s for user %s" % (fleet_srp, request.user))

    if request.method == 'POST':
        form = SrpFleetUserRequestForm(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.objects.get(fleet_srp_code=fleet_srp)
            post_time = timezone.now()
            srp_status = "Pending"

            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.srp_status = srp_status

            try:
                srp_kill_link = srpManager.get_kill_id(srp_request.killboard_link)
                (srp_kill_data, ship_value) = srpManager.get_kill_data(srp_kill_link)
            except ValueError:
                logger.debug("User %s Submitted Invalid Killmail Link %s or server could not be reached" % (request.user, srp_request.killboard_link))
                notify(request.user, "Your SRP request Killmail Link Failed Validation", message="Your SRP request Killmail link %s is invalid. Please make sure your using zKillboard." % srp_request.killboard_link, level="danger")
                return HttpResponseRedirect("/srp")
            srp_ship_name = srpManager.get_ship_name(srp_kill_data)
            srp_request.srp_ship_name = srp_ship_name
            kb_total_loss = ship_value
            srp_request.kb_total_loss = kb_total_loss
            srp_request.post_time = post_time
            srp_request.save()
            completed = True
            logger.info("Created SRP Request on behalf of user %s for fleet name %s" % (request.user, srp_fleet_main.fleet_name))

    else:
        logger.debug("Returning blank SrpFleetUserRequestForm")
        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))
Ejemplo n.º 29
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 change:
        notify(user,
               "Services Disabled",
               message="Your services accounts have been disabled.",
               level="danger")
Ejemplo n.º 30
0
def group_accept_request(request, group_request_id):
    logger.debug(
        "group_accept_request called by user %s for grouprequest id %s" %
        (request.user, group_request_id))
    try:
        group_request = GroupRequest.objects.get(id=group_request_id)
        group, created = Group.objects.get_or_create(
            name=group_request.group.name)

        if not GroupManager.joinable_group(group_request.group) or \
                not GroupManager.can_manage_group(request.user, group_request.group):
            raise PermissionDenied

        group_request.user.groups.add(group)
        group_request.user.save()
        group_request.delete()
        logger.info(
            "User %s accepted group request from user %s to group %s" %
            (request.user, group_request.user, group_request.group.name))
        notify(group_request.user,
               "Group Application Accepted",
               level="success",
               message="Your application to %s has been accepted." %
               group_request.group)
        messages.success(
            request,
            _('Accepted application from %(mainchar)s to %(group)s.') % {
                "mainchar": group_request.main_char,
                "group": group_request.group
            })

    except PermissionDenied as p:
        logger.warning(
            "User %s attempted to accept group join request %s but permission was denied"
            % (request.user, group_request_id))
        raise p
    except:
        messages.error(
            request,
            _('An unhandled error occurred while processing the application from %(mainchar)s to %(group)s.'
              ) % {
                  "mainchar": group_request.main_char,
                  "group": group_request.group
              })
        logger.exception(
            "Unhandled exception occurred while user %s attempting to accept grouprequest id %s."
            % (request.user, group_request_id))
        pass

    return redirect("auth_group_management")