Commit b0eb658d authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

astakos: Remove membership policy settings

Available join and leave policies are internally defined and should
not be changed by settings. Move policy descriptions to presentation.py.

Do not convert to string the lookup key in templatetags/filters.py
parent 1b7abb22
......@@ -142,8 +142,6 @@ ASTAKOS_ENABLE_LOCAL_ACCOUNT_MIGRATION True
ASTAKOS_RESOURCES_PRESENTATION_DATA {} Customizes resource presentation
ASTAKOS_ENABLE_LOCAL_ACCOUNT_MIGRATION True Permits local account migration
ASTAKOS_SHIBBOLETH_REQUIRE_NAME_INFO False Strict shibboleth usage
ASTAKOS_PROJECT_MEMBER_JOIN_POLICIES {'1':'automatically accepted', '2':'owner accepts', '3':'closed'} Text to be displayed in project member join policy dropdown
ASTAKOS_PROJECT_MEMBER_LEAVE_POLICIES {'1':'automatically accepted', '2':'owner accepts', '3':'closed'} Text to be displayed in project member leave policy dropdown
ASTAKOS_ACTIVATION_REDIRECT_URL "/im/landing"
ASTAKOS_TRANSLATE_UUIDS False If true, this enables a ui compatibility layer for the introduction of UUIDs in identity management.
WARNING: Setting to True will break your installation.
......
......@@ -35,7 +35,8 @@ from astakos.im.settings import (
IM_MODULES, INVITATIONS_ENABLED, IM_STATIC_URL,
LOGIN_MESSAGES, SIGNUP_MESSAGES, PROFILE_MESSAGES,
GLOBAL_MESSAGES, PROFILE_EXTRA_LINKS,
PROJECT_MEMBER_JOIN_POLICIES, PROJECT_MEMBER_LEAVE_POLICIES)
)
from astakos.im import presentation
from astakos.api import get_menu
from astakos.im.util import get_query
from astakos.im.auth_providers import PROVIDERS as AUTH_PROVIDERS
......@@ -110,6 +111,6 @@ def menu(request):
return {'menu': menu_items}
def membership_policies(request):
return {'join_policies':PROJECT_MEMBER_JOIN_POLICIES,
'leave_policies':PROJECT_MEMBER_LEAVE_POLICIES}
return {'join_policies': presentation.PROJECT_MEMBER_JOIN_POLICIES,
'leave_policies': presentation.PROJECT_MEMBER_LEAVE_POLICIES}
......@@ -63,8 +63,7 @@ from astakos.im.settings import (
INVITATIONS_PER_LEVEL, BASEURL, SITENAME, RECAPTCHA_PRIVATE_KEY,
RECAPTCHA_ENABLED, CONTACT_EMAIL, LOGGING_LEVEL,
PASSWORD_RESET_EMAIL_SUBJECT, NEWPASSWD_INVALIDATE_TOKEN,
MODERATION_ENABLED, PROJECT_MEMBER_JOIN_POLICIES,
PROJECT_MEMBER_LEAVE_POLICIES, EMAILCHANGE_ENABLED,
MODERATION_ENABLED, EMAILCHANGE_ENABLED,
)
from astakos.im import presentation
from astakos.im.widgets import DummyWidget, RecaptchaWidget
......@@ -744,8 +743,8 @@ max_members_help = _("""
If you are not certain, it is best to start with a conservative
limit. You can always request a raise when you need it.""")
join_policies = PROJECT_MEMBER_JOIN_POLICIES.iteritems()
leave_policies = PROJECT_MEMBER_LEAVE_POLICIES.iteritems()
join_policies = presentation.PROJECT_MEMBER_JOIN_POLICIES.items()
leave_policies = presentation.PROJECT_MEMBER_LEAVE_POLICIES.items()
class ProjectApplicationForm(forms.ModelForm):
......@@ -814,8 +813,8 @@ class ProjectApplicationForm(forms.ModelForm):
super(ProjectApplicationForm, self).__init__(*args, **kwargs)
# in case of new application remove closed join policy
if not instance:
policies = PROJECT_MEMBER_JOIN_POLICIES.copy()
policies.pop('3')
policies = presentation.PROJECT_MEMBER_JOIN_POLICIES.copy()
policies.pop(3)
self.fields['member_join_policy'].choices = policies.iteritems()
def clean_start_date(self):
......
......@@ -62,7 +62,7 @@ from astakos.im.settings import (
PROJECT_CREATION_SUBJECT, PROJECT_APPROVED_SUBJECT,
PROJECT_TERMINATION_SUBJECT, PROJECT_SUSPENSION_SUBJECT,
PROJECT_MEMBERSHIP_CHANGE_SUBJECT,
PROJECT_MEMBER_JOIN_POLICIES, PROJECT_MEMBER_LEAVE_POLICIES)
)
from astakos.im.notifications import build_notification, NotificationError
from astakos.im.models import (
AstakosUser, Invitation, ProjectMembership, ProjectApplication, Project,
......
......@@ -70,7 +70,7 @@ from astakos.im.settings import (
DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL,
AUTH_TOKEN_DURATION, EMAILCHANGE_ACTIVATION_DAYS, LOGGING_LEVEL,
SITENAME, MODERATION_ENABLED,
PROJECT_MEMBER_JOIN_POLICIES, PROJECT_MEMBER_LEAVE_POLICIES)
)
from astakos.im import settings as astakos_settings
from astakos.im import auth_providers as auth
......@@ -1636,11 +1636,13 @@ class ProjectApplication(models.Model):
@property
def member_join_policy_display(self):
return PROJECT_MEMBER_JOIN_POLICIES.get(str(self.member_join_policy))
policy = self.member_join_policy
return presentation.PROJECT_MEMBER_JOIN_POLICIES.get(policy)
@property
def member_leave_policy_display(self):
return PROJECT_MEMBER_LEAVE_POLICIES.get(str(self.member_leave_policy))
policy = self.member_leave_policy
return presentation.PROJECT_MEMBER_LEAVE_POLICIES.get(policy)
class ProjectResourceGrant(models.Model):
......
......@@ -228,3 +228,17 @@ SERVICES = {
}
}
}
PROJECT_MEMBER_JOIN_POLICIES = {
1: 'automatically accepted',
2: 'owner accepts',
3: 'closed',
}
PROJECT_MEMBER_LEAVE_POLICIES = {
1: 'automatically accepted',
2: 'owner accepts',
3: 'closed',
}
......@@ -182,23 +182,10 @@ SHIBBOLETH_REQUIRE_NAME_INFO = getattr(settings,
'ASTAKOS_SHIBBOLETH_REQUIRE_NAME_INFO',
False)
PROJECT_MEMBER_JOIN_POLICIES = getattr(settings,
'ASTAKOS_PROJECT_MEMBER_JOIN_POLICIES',
{'1':'automatically accepted',
'2':'owner accepts',
'3':'closed'})
PROJECT_MEMBER_LEAVE_POLICIES = getattr(settings,
'ASTAKOS_PROJECT_MEMBER_LEAVE_POLICIES',
{'1':'automatically accepted',
'2':'owner accepts',
'3':'closed'})
ACTIVATION_REDIRECT_URL = getattr(settings,
'ASTAKOS_ACTIVATION_REDIRECT_URL',
"/im/landing")
# If true, this enables a ui compatibility layer for the introduction of UUIDs
# in identity management. WARNING: Setting to True will break your installation.
TRANSLATE_UUIDS = getattr(settings, 'ASTAKOS_TRANSLATE_UUIDS', False)
......
......@@ -87,7 +87,7 @@ def to_string(s):
@register.filter
def lookup(d, key):
try:
return d.get(str(key))
return d.get(key)
except:
return
......
......@@ -266,14 +266,6 @@
# Strict shibboleth usage
#ASTAKOS_SHIBBOLETH_REQUIRE_NAME_INFO = False
#ASTAKOS_PROJECT_MEMBER_JOIN_POLICIES = {'1':'automatically accepted',
# '2':'owner accepts',
# '3':'closed'}
#ASTAKOS_PROJECT_MEMBER_LEAVE_POLICIES' = {'1':'automatically accepted',
# '2':'owner accepts',
# '3':'closed'}
#ASTAKOS_ACTIVATION_REDIRECT_URL = "/im/landing"
# If true, this enables a ui compatibility layer for the introduction
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment