mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 20:40:17 +02:00
* Port to Django 1.10 Initial migrations for current states of all models. Requires faking to retain data. Removed all references to render_to_response, replacing with render shortcut. Same for HttpResponseRedirect to render shortcut. Corrected notification signal import to wait for app registry to finish loading. * Correct typos from render conversion * Modify models to suppress Django field warnings * Script for automatic database conversion - fakes initial migrations to preserve data Include LOGIN_URL setting * Correct context processor import typo * Removed pathfinder support. Current pathfinder versions require SSO, not APIs added to database. Conditionally load additional database definitions only if services are enabled. Prevents errors when running auth without creating all possible databases. * Condense context processors * Include Django 1.10 installation in migrate script Remove syncdb/evolve, replace with migrate for update script * Replaced member/blue perms with user state system Removed sigtracker Initial migrations for default perms and groups Removed perm bootstrapping on first run * Clean up services list * Remove fleet fittings page * Provide action feedback via django messaging Display unread notification count Correct left navbar alignment * Stop storing service passwords. Provide them one time upon activation or reset. Closes #177 * Add group sync buttons to admin site Allow searcing of AuthServicesInfo models Display user main character * Correct button CSS to remove underlines on hover * Added bulk actions to notifications Altered notification default ordering * Centralize API key validation. Remove unused error count on API key model. Restructure API key refresh task to queue all keys per user and await completion. Closes #350 * Example configuration files for supervisor. Copy to /etc/supervisor/conf.d and restart to take effect. Closes #521 Closes #266 * Pre-save receiver for member/blue state switching Removed is_blue field Added link to admin site * Remove all hardcoded URLs from views and templates Correct missing render arguments Closes #540 * Correct celeryd process directory * Migration to automatically set user states. Runs instead of waiting for next API refresh cycle. Should make the transition much easier. * Verify service accounts accessible to member state * Restructure project to remove unnecessary apps. (celerytask, util, portal, registraion apps) Added workarounds for python 3 compatibility. * Correct python2 compatibility * Check services against state being changed to * Python3 compatibility fixes * Relocate x2bool py3 fix * SSO integration for logging in to existing accounts. * Add missing url names for fleetup reverse * Sanitize groupnames before syncing. * Correct trailing slash preventing url resolution * Alter group name sanitization to allow periods and hyphens * Correct state check on pre_save model for corp/alliance group assignment * Remove sigtracker table from old dbs to allow user deletion * Include missing celery configuration * Teamspeak error handling * Prevent celery worker deadlock on async group result wait * Correct active navbar links for translated urls. Correct corp status url resolution for some links. Remove DiscordAuthToken model.
99 lines
3.9 KiB
Python
99 lines
3.9 KiB
Python
from __future__ import unicode_literals
|
|
from django.db.models.signals import m2m_changed
|
|
from django.db.models.signals import post_save
|
|
from django.db.models.signals import pre_save
|
|
from django.db.models.signals import post_delete
|
|
from django.db.models.signals import pre_delete
|
|
from django.dispatch import receiver
|
|
from django.contrib.auth.models import User
|
|
import logging
|
|
from services.tasks import update_jabber_groups
|
|
from services.tasks import update_mumble_groups
|
|
from services.tasks import update_forum_groups
|
|
from services.tasks import update_ipboard_groups
|
|
from services.tasks import update_discord_groups
|
|
from services.tasks import update_teamspeak3_groups
|
|
from services.tasks import update_discourse_groups
|
|
from services.tasks import update_smf_groups
|
|
from authentication.tasks import set_state
|
|
from authentication.tasks import disable_member
|
|
from authentication.models import AuthServicesInfo
|
|
from services.models import AuthTS
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@receiver(m2m_changed, sender=User.groups.through)
|
|
def m2m_changed_user_groups(sender, instance, action, *args, **kwargs):
|
|
logger.debug("Received m2m_changed from %s groups with action %s" % (instance, action))
|
|
if action == "post_add" or action == "post_remove" or action == "post_clear":
|
|
logger.debug("Triggering service group update for %s" % instance)
|
|
auth, c = AuthServicesInfo.objects.get_or_create(user=instance)
|
|
if auth.jabber_username:
|
|
update_jabber_groups.delay(instance.pk)
|
|
if auth.teamspeak3_uid:
|
|
update_teamspeak3_groups.delay(instance.pk)
|
|
if auth.forum_username:
|
|
update_forum_groups.delay(instance.pk)
|
|
if auth.smf_username:
|
|
update_smf_groups.delay(instance.pk)
|
|
if auth.ipboard_username:
|
|
update_ipboard_groups.delay(instance.pk)
|
|
if auth.discord_uid:
|
|
update_discord_groups.delay(instance.pk)
|
|
if auth.mumble_username:
|
|
update_mumble_groups.delay(instance.pk)
|
|
if auth.discourse_username:
|
|
update_discourse_groups.delay(instance.pk)
|
|
if auth.smf_username:
|
|
update_smf_groups.delay(instance.pk)
|
|
|
|
|
|
def trigger_all_ts_update():
|
|
for auth in AuthServicesInfo.objects.filter(teamspeak3_uid__isnull=False):
|
|
update_teamspeak3_groups.delay(auth.user.pk)
|
|
|
|
|
|
@receiver(m2m_changed, sender=AuthTS.ts_group.through)
|
|
def m2m_changed_authts_group(sender, instance, action, *args, **kwargs):
|
|
logger.debug("Received m2m_changed from %s ts_group with action %s" % (instance, action))
|
|
if action == "post_add" or action == "post_remove":
|
|
trigger_all_ts_update()
|
|
|
|
|
|
@receiver(post_save, sender=AuthTS)
|
|
def post_save_authts(sender, instance, *args, **kwargs):
|
|
logger.debug("Received post_save from %s" % instance)
|
|
trigger_all_ts_update()
|
|
|
|
|
|
@receiver(post_delete, sender=AuthTS)
|
|
def post_delete_authts(sender, instance, *args, **kwargs):
|
|
logger.debug("Received post_delete signal from %s" % instance)
|
|
trigger_all_ts_update()
|
|
|
|
|
|
@receiver(pre_delete, sender=User)
|
|
def pre_delete_user(sender, instance, *args, **kwargs):
|
|
logger.debug("Received pre_delete from %s" % instance)
|
|
disable_member(instance)
|
|
|
|
|
|
@receiver(pre_save, sender=User)
|
|
def pre_save_user(sender, instance, *args, **kwargs):
|
|
logger.debug("Received pre_save from %s" % instance)
|
|
# check if user is being marked active/inactive
|
|
if not instance.pk:
|
|
# new model being created
|
|
return
|
|
try:
|
|
old_instance = User.objects.get(pk=instance.pk)
|
|
if old_instance.is_active and not instance.is_active:
|
|
logger.info("Disabling services for inactivation of user %s" % instance)
|
|
disable_member(instance)
|
|
elif instance.is_active and not old_instance.is_active:
|
|
logger.info("Assessing state of reactivated user %s" % instance)
|
|
set_state(instance)
|
|
except User.DoesNotExist:
|
|
pass
|