Commit 7e823cf0 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Merge branch 'latest-quota' of https://code.grnet.gr/git/synnefo into latest-quota

parents 708ef05c b6199b34
......@@ -34,7 +34,8 @@
from astakos.im.settings import (
IM_MODULES, INVITATIONS_ENABLED, IM_STATIC_URL,
LOGIN_MESSAGES, SIGNUP_MESSAGES, PROFILE_MESSAGES,
GLOBAL_MESSAGES, PROFILE_EXTRA_LINKS)
GLOBAL_MESSAGES, PROFILE_EXTRA_LINKS,
PROJECT_MEMBER_JOIN_POLICIES, PROJECT_MEMBER_LEAVE_POLICIES)
from astakos.im.api import get_menu
from astakos.im.util import get_query
from astakos.im.auth_providers import PROVIDERS as AUTH_PROVIDERS
......@@ -107,3 +108,8 @@ def menu(request):
return {}
else:
return {'menu': menu_items}
def membership_policies(request):
return {'join_policies':PROJECT_MEMBER_JOIN_POLICIES,
'leave_policies':PROJECT_MEMBER_LEAVE_POLICIES}
......@@ -56,12 +56,13 @@ from django.contrib.auth.models import AnonymousUser
from astakos.im.models import (
AstakosUser, EmailChange, Invitation,
Resource, PendingThirdPartyUser, get_latest_terms, RESOURCE_SEPARATOR,
ProjectApplication, MemberJoinPolicy, MemberLeavePolicy)
ProjectApplication)
from astakos.im.settings import (
INVITATIONS_PER_LEVEL, BASEURL, SITENAME, RECAPTCHA_PRIVATE_KEY,
RECAPTCHA_ENABLED, DEFAULT_CONTACT_EMAIL, LOGGING_LEVEL,
PASSWORD_RESET_EMAIL_SUBJECT, NEWPASSWD_INVALIDATE_TOKEN,
MODERATION_ENABLED)
MODERATION_ENABLED, PROJECT_MEMBER_JOIN_POLICIES,
PROJECT_MEMBER_LEAVE_POLICIES)
from astakos.im.widgets import DummyWidget, RecaptchaWidget
from astakos.im.functions import send_change_email, submit_application
......@@ -650,13 +651,10 @@ class ProjectApplicationForm(forms.ModelForm):
required=False
)
comments = forms.CharField(widget=forms.Textarea, required=False)
member_join_policy = forms.ModelChoiceField(
queryset=MemberJoinPolicy.objects.all(),
empty_label=None)
member_leave_policy = forms.ModelChoiceField(
queryset=MemberLeavePolicy.objects.all(),
empty_label=None)
member_join_policy = forms.ChoiceField(
choices=PROJECT_MEMBER_JOIN_POLICIES.iteritems())
member_leave_policy = forms.ChoiceField(
choices=PROJECT_MEMBER_LEAVE_POLICIES.iteritems())
class Meta:
model = ProjectApplication
......
......@@ -61,11 +61,11 @@ from astakos.im.settings import (
EMAIL_CHANGE_EMAIL_SUBJECT,
PROJECT_CREATION_SUBJECT, PROJECT_APPROVED_SUBJECT,
PROJECT_TERMINATION_SUBJECT, PROJECT_SUSPENSION_SUBJECT,
PROJECT_MEMBERSHIP_CHANGE_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, ProjectMembership, ProjectApplication, Project,
MemberLeavePolicy, MemberJoinPolicy,
trigger_sync)
import astakos.im.messages as astakos_messages
......@@ -368,17 +368,11 @@ class SendNotificationError(SendMailError):
### PROJECT VIEWS ###
def get_join_policy(str_policy):
try:
return MemberJoinPolicy.objects.get(policy=str_policy)
except:
return None
return PROJECT_MEMBER_JOIN_POLICIES.get(str_policy)
def get_leave_policy(str_policy):
try:
return MemberLeavePolicy.objects.get(policy=str_policy)
except BaseException, e:
return None
return PROJECT_MEMBER_LEAVE_POLICIES.get(str_policy)
_auto_accept_join = None
def get_auto_accept_join_policy():
global _auto_accept_join
......
......@@ -1004,20 +1004,6 @@ class SessionCatalog(models.Model):
### PROJECTS ###
################
class MemberJoinPolicy(models.Model):
policy = models.CharField(_('Policy'), max_length=255, unique=True, db_index=True)
description = models.CharField(_('Description'), max_length=80)
def __str__(self):
return self.description.capitalize()
class MemberLeavePolicy(models.Model):
policy = models.CharField(_('Policy'), max_length=255, unique=True, db_index=True)
description = models.CharField(_('Description'), max_length=80)
def __str__(self):
return self.description.capitalize()
def synced_model_metaclass(class_name, class_parents, class_attributes):
new_attributes = {}
......@@ -1176,8 +1162,8 @@ class ProjectApplication(models.Model):
help_text=_("Please provide a short but descriptive abstract of your Project, so that anyone searching can quickly understand what this Project is about. "))
start_date = models.DateTimeField(help_text=_("Here you specify the date you want your Project to start granting its resources. Its members will get the resources coming from this Project on this exact date."))
end_date = models.DateTimeField(help_text=_("Here you specify the date you want your Project to cease. This means that after this date all members will no longer be able to allocate resources from this Project. "))
member_join_policy = models.ForeignKey(MemberJoinPolicy)
member_leave_policy = models.ForeignKey(MemberLeavePolicy)
member_join_policy = models.IntegerField()
member_leave_policy = models.IntegerField()
limit_on_members_number = models.PositiveIntegerField(null=True,
blank=True,help_text=_("Here you specify the number of members this Project is going to have. This means that this number of people will be granted the resources you will specify in the next step. This can be '1' if you are the only one wanting to get resources. "))
resource_grants = models.ManyToManyField(
......
......@@ -303,3 +303,15 @@ ENABLE_LOCAL_ACCOUNT_MIGRATION = getattr(settings, 'ASTAKOS_ENABLE_LOCAL_ACCOUNT
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 by the system',
2:'accepted by the owner of the project',
3:'members can not join the project'})
PROJECT_MEMBER_LEAVE_POLICIES = getattr(settings,
'ASTAKOS_PROJECT_MEMBER_LEAVE_POLICIES',
{1:'automatically accepted by the system',
2:'accepted by the owner of the project',
3:'members can not leave the project'})
......@@ -60,6 +60,7 @@ context_processors = [
'astakos.im.context_processors.menu',
'astakos.im.context_processors.custom_messages',
'astakos.im.context_processors.last_login_method',
'astakos.im.context_processors.membership_policies',
'synnefo.lib.context_processors.cloudbar'
]
......
......@@ -81,11 +81,11 @@
<dd>{% if object.limit_on_members_number%}{{object.limit_on_members_number}}{% else %}&nbsp;{% endif %}</dd>
<dt>Member join policy</dt>
<dd>
{{ object.member_join_policy }}
{{ join_policies|lookup:object.member_join_policy }}
</dd>
<dt>Member leave policy</dt>
<dd>
{{ object.member_leave_policy }}
{{ leave_policies|lookup:object.member_leave_policy }}
</dd>
</dl>
</div>
......
......@@ -37,9 +37,9 @@
<h3>MEMBERSHIP OPTIONS</h3>
<dl class="alt-style">
<dt>Member join policy</dt>
<dd>{{ form_data.member_join_policy }}</dd>
<dd>{{ join_policies|lookup:form_data.member_join_policy }}</dd>
<dt>Member leave policy</dt>
<dd>{{ form_data.member_leave_policy }}</dd>
<dd>{{ leave_policies|lookup:form_data.member_leave_policy }}</dd>
<dt>Total number of members</dt>
<dd>{{ form_data.limit_on_members_number }}</dd>
</dl>
......
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