From abc214ea182dd7d06d718e3a3361564b4c23d6c7 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Sat, 8 May 2010 18:03:24 +0100 Subject: [PATCH] Now allows access permissions on a alliance level --- eve_api/evolutions/__init__.py | 2 +- eve_api/evolutions/alliance-group.py | 7 +++++++ eve_api/models/api_player.py | 1 + sso/models.py | 10 ++++++++-- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 eve_api/evolutions/alliance-group.py diff --git a/eve_api/evolutions/__init__.py b/eve_api/evolutions/__init__.py index 4b9c9d6..025c9cb 100644 --- a/eve_api/evolutions/__init__.py +++ b/eve_api/evolutions/__init__.py @@ -1 +1 @@ -SEQUENCE = ['applications-field', 'total-sp', 'login-locations', 'director-update'] +SEQUENCE = ['applications-field', 'total-sp', 'login-locations', 'director-update', 'alliance-group'] diff --git a/eve_api/evolutions/alliance-group.py b/eve_api/evolutions/alliance-group.py new file mode 100644 index 0000000..5b0f3c6 --- /dev/null +++ b/eve_api/evolutions/alliance-group.py @@ -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') +] + diff --git a/eve_api/models/api_player.py b/eve_api/models/api_player.py index b97a098..0f671fa 100644 --- a/eve_api/models/api_player.py +++ b/eve_api/models/api_player.py @@ -126,6 +126,7 @@ class EVEPlayerAlliance(EVEAPIModel): #executor_character = models.ForeignKey(EVECharacter, blank=True, null=False) member_count = models.IntegerField(blank=True, null=True) date_founded = models.DateField(blank=True, null=True) + group = models.ForeignKey(Group, blank=True, null=True) objects = EVEPlayerAllianceManager() diff --git a/sso/models.py b/sso/models.py index 5b7e89f..bc2a0b9 100644 --- a/sso/models.py +++ b/sso/models.py @@ -5,7 +5,7 @@ import logging from django.db import models from django.db.models import signals 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 services import get_api @@ -48,11 +48,14 @@ class SSOUser(models.Model): access accordingly """ 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 = [] for corp in EVEPlayerCorporation.objects.filter(group__isnull=False): if 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 chargroups = [] @@ -61,6 +64,9 @@ class SSOUser(models.Model): for char in eacc.characters.all(): if 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 delgroups = set(set(self.user.groups.all()) & set(corpgroups)) - set(chargroups)