mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Now allows access permissions on a alliance level
This commit is contained in:
@@ -1 +1 @@
|
|||||||
SEQUENCE = ['applications-field', 'total-sp', 'login-locations', 'director-update']
|
SEQUENCE = ['applications-field', 'total-sp', 'login-locations', 'director-update', 'alliance-group']
|
||||||
|
|||||||
7
eve_api/evolutions/alliance-group.py
Normal file
7
eve_api/evolutions/alliance-group.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from django_evolution.mutations import *
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
MUTATIONS = [
|
||||||
|
AddField('EVEPlayerAlliance', 'group', models.ForeignKey, null=True, related_model='auth.Group')
|
||||||
|
]
|
||||||
|
|
||||||
@@ -126,6 +126,7 @@ class EVEPlayerAlliance(EVEAPIModel):
|
|||||||
#executor_character = models.ForeignKey(EVECharacter, blank=True, null=False)
|
#executor_character = models.ForeignKey(EVECharacter, blank=True, null=False)
|
||||||
member_count = models.IntegerField(blank=True, null=True)
|
member_count = models.IntegerField(blank=True, null=True)
|
||||||
date_founded = models.DateField(blank=True, null=True)
|
date_founded = models.DateField(blank=True, null=True)
|
||||||
|
group = models.ForeignKey(Group, blank=True, null=True)
|
||||||
|
|
||||||
objects = EVEPlayerAllianceManager()
|
objects = EVEPlayerAllianceManager()
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import logging
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import signals
|
from django.db.models import signals
|
||||||
from django.contrib.auth.models import User, UserManager, Group
|
from django.contrib.auth.models import User, UserManager, Group
|
||||||
from eve_api.models import EVEAccount, EVEPlayerCorporation
|
from eve_api.models import EVEAccount, EVEPlayerCorporation, EVEPlayerAlliance
|
||||||
from reddit.models import RedditAccount
|
from reddit.models import RedditAccount
|
||||||
|
|
||||||
from services import get_api
|
from services import get_api
|
||||||
@@ -48,11 +48,14 @@ class SSOUser(models.Model):
|
|||||||
access accordingly """
|
access accordingly """
|
||||||
|
|
||||||
self._log.debug("Update - User %s" % self.user)
|
self._log.debug("Update - User %s" % self.user)
|
||||||
# Create a list of all Corp groups
|
# Create a list of all Corp and Alliance groups
|
||||||
corpgroups = []
|
corpgroups = []
|
||||||
for corp in EVEPlayerCorporation.objects.filter(group__isnull=False):
|
for corp in EVEPlayerCorporation.objects.filter(group__isnull=False):
|
||||||
if corp.group:
|
if corp.group:
|
||||||
corpgroups.append(corp.group)
|
corpgroups.append(corp.group)
|
||||||
|
for alliance in EVEPlayerAlliance.objects.filter(group__isnull=False):
|
||||||
|
if alliance.group:
|
||||||
|
corpgroups.append(alliance.group)
|
||||||
|
|
||||||
# Create a list of Char groups
|
# Create a list of Char groups
|
||||||
chargroups = []
|
chargroups = []
|
||||||
@@ -61,6 +64,9 @@ class SSOUser(models.Model):
|
|||||||
for char in eacc.characters.all():
|
for char in eacc.characters.all():
|
||||||
if char.corporation.group:
|
if char.corporation.group:
|
||||||
chargroups.append(char.corporation.group)
|
chargroups.append(char.corporation.group)
|
||||||
|
if char.corporation.alliance:
|
||||||
|
if char.corporation.alliance.group:
|
||||||
|
chargroups.append(char.corporation.alliance.group)
|
||||||
|
|
||||||
# Generate the list of groups to add/remove
|
# Generate the list of groups to add/remove
|
||||||
delgroups = set(set(self.user.groups.all()) & set(corpgroups)) - set(chargroups)
|
delgroups = set(set(self.user.groups.all()) & set(corpgroups)) - set(chargroups)
|
||||||
|
|||||||
Reference in New Issue
Block a user