def jabber_broadcast_view(request): success = False if request.method == 'POST': form = JabberBroadcastForm(request.POST) if form.is_valid(): user_info = AuthServicesInfo.objects.get(user=request.user) main_char = EveCharacter.objects.get(character_id=user_info.main_char_id) if user_info.main_char_id != "": message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + main_char.character_name + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n" group_to_send = form.cleaned_data['group'] OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,) else: message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n" group_to_send = form.cleaned_data['group'] OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,) success = True else: form = JabberBroadcastForm() context = {'form': form, 'success': success} return render_to_response('registered/jabberbroadcast.html', context, context_instance=RequestContext(request))
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'] 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))
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))
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")
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")
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")
def jabber_broadcast_view(request): success = False if request.method == 'POST': form = JabberBroadcastForm(request.POST) if form.is_valid(): user_info = AuthServicesInfo.objects.get(user=request.user) main_char = EveCharacter.objects.get( character_id=user_info.main_char_id) if user_info.main_char_id != "": message_to_send = form.cleaned_data[ 'message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + main_char.character_name + " TO: " + form.cleaned_data[ 'group'] + " WHEN: " + datetime.datetime.utcnow( ).strftime( "%Y-%m-%d %H:%M:%S" ) + " #####\n##### Replies are NOT monitored #####\n" group_to_send = form.cleaned_data['group'] OpenfireManager.send_broadcast_threaded( group_to_send, message_to_send, ) else: message_to_send = form.cleaned_data[ 'message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + form.cleaned_data[ 'group'] + " WHEN: " + datetime.datetime.utcnow( ).strftime( "%Y-%m-%d %H:%M:%S" ) + " #####\n##### Replies are NOT monitored #####\n" group_to_send = form.cleaned_data['group'] OpenfireManager.send_broadcast_threaded( group_to_send, message_to_send, ) success = True else: form = JabberBroadcastForm() context = {'form': form, 'success': success} return render_to_response('registered/jabberbroadcast.html', context, context_instance=RequestContext(request))
def activate_jabber(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) character = EveManager.get_character_by_id(authinfo.main_char_id) info = OpenfireManager.add_user(character.character_name) # If our username is blank means we already had a user if info[0] is not "": AuthServicesInfoManager.update_user_jabber_info(info[0], info[1], request.user) update_jabber_groups(request.user) return HttpResponseRedirect("/services/") return HttpResponseRedirect("/dashboard")
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")
def deactivate_jabber(request): logger.debug("deactivate_jabber called by user %s" % request.user) authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) result = OpenfireManager.delete_user(authinfo.jabber_username) # If our username is blank means we failed if result: AuthServicesInfoManager.update_user_jabber_info("", "", request.user) logger.info("Succesfully deactivated jabber for user %s" % request.user) return HttpResponseRedirect("/services/") logger.error("Unsuccesful attempt to deactivate jabber for user %s" % request.user) return HttpResponseRedirect("/dashboard")
def activate_jabber(request): authinfo = AuthServicesInfoManager.get_auth_service_info(request.user) character = EveManager.get_character_by_id(authinfo.main_char_id) info = OpenfireManager.add_user(character.character_name) # If our username is blank means we already had a user if info[0] is not "": AuthServicesInfoManager.update_user_jabber_info( info[0], info[1], request.user) update_jabber_groups(request.user) return HttpResponseRedirect("/services/") return HttpResponseRedirect("/dashboard")
def jabber_broadcast_view(request): logger.debug("jabber_broadcast_view called by user %s" % request.user) success = False allchoices = [] if check_if_user_has_permission(request.user, 'jabber_broadcast_all'): allchoices.append(('all', 'all')) for g in Group.objects.all(): allchoices.append((str(g.name), str(g.name))) else: for g in request.user.groups.all(): allchoices.append((str(g.name), str(g.name))) if request.method == 'POST': form = JabberBroadcastForm(request.POST) form.fields['group'].choices = allchoices logger.debug("Received POST request containing form, valid: %s" % form.is_valid()) if form.is_valid(): user_info = AuthServicesInfo.objects.get(user=request.user) main_char = EveCharacter.objects.get(character_id=user_info.main_char_id) logger.debug("Processing jabber broadcast for user %s with main character %s" % (user_info, main_char)) if user_info.main_char_id != "": message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + main_char.character_name + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n" group_to_send = form.cleaned_data['group'] OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,) else: message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n" group_to_send = form.cleaned_data['group'] OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,) success = True logger.info("Sent jabber broadcast on behalf of user %s" % request.user) else: form = JabberBroadcastForm() form.fields['group'].choices = allchoices logger.debug("Generated broadcast form for user %s containing %s groups" % (request.user, len(form.fields['group'].choices))) context = {'form': form, 'success': success} return render_to_response('registered/jabberbroadcast.html', context, context_instance=RequestContext(request))
def activate_jabber(request): logger.debug("activate_jabber 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 jabber user for user %s with main character %s" % (request.user, character)) info = OpenfireManager.add_user(character.character_name) # If our username is blank means we already had a user if info[0] is not "": AuthServicesInfoManager.update_user_jabber_info(info[0], info[1], request.user) logger.debug("Updated authserviceinfo for user %s with jabber credentials. Updating groups." % request.user) update_jabber_groups.delay(request.user.pk) logger.info("Succesfully activated jabber for user %s" % request.user) return HttpResponseRedirect("/services/") logger.error("Unsuccesful attempt to activate jabber for user %s" % request.user) return HttpResponseRedirect("/dashboard")
def activate_jabber(request): logger.debug("activate_jabber 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 jabber user for user %s with main character %s" % (request.user, character)) info = OpenfireManager.add_user(character.character_name) # If our username is blank means we already had a user if info[0] is not "": AuthServicesInfoManager.update_user_jabber_info(info[0], info[1], request.user) logger.debug("Updated authserviceinfo for user %s with jabber credentials. Updating groups." % request.user) update_jabber_groups(request.user) logger.info("Succesfully activated jabber for user %s" % request.user) return HttpResponseRedirect("/services/") logger.error("Unsuccesful attempt to activate jabber for user %s" % request.user) return HttpResponseRedirect("/dashboard")