Commit c495a93b authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

astakos: Make base project when creating user

Make base project along with the user with the same uuid. Enable the
project upon user acceptance.
parent a544e7c7
...@@ -40,8 +40,6 @@ from astakos.im import functions ...@@ -40,8 +40,6 @@ from astakos.im import functions
from astakos.im import settings from astakos.im import settings
from astakos.im import forms from astakos.im import forms
from astakos.im.quotas import qh_sync_new_user
import astakos.im.messages as astakos_messages import astakos.im.messages as astakos_messages
import datetime import datetime
...@@ -255,7 +253,7 @@ class ActivationBackend(object): ...@@ -255,7 +253,7 @@ class ActivationBackend(object):
default=lambda obj: default=lambda obj:
str(obj)) str(obj))
user.save() user.save()
qh_sync_new_user(user) functions.enable_base_project(user)
if user.is_rejected: if user.is_rejected:
logger.warning("User has previously been " logger.warning("User has previously been "
......
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
# interpreted as representing official policies, either expressed # interpreted as representing official policies, either expressed
# or implied, of GRNET S.A. # or implied, of GRNET S.A.
import uuid
import datetime import datetime
from astakos.im import models from astakos.im import models
from astakos.im import functions
def _finalize_astakosuser_object(user, has_signed_terms=False): def _finalize_astakosuser_object(user, has_signed_terms=False):
...@@ -43,7 +43,9 @@ def _finalize_astakosuser_object(user, has_signed_terms=False): ...@@ -43,7 +43,9 @@ def _finalize_astakosuser_object(user, has_signed_terms=False):
user.date_signed_terms = datetime.datetime.now() user.date_signed_terms = datetime.datetime.now()
user.renew_verification_code() user.renew_verification_code()
user.uuid = str(uuid.uuid4()) project = functions.make_base_project(user.username)
user.base_project = project
user.uuid = project.uuid
user.renew_token() user.renew_token()
user.save() user.save()
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
# or implied, of GRNET S.A. # or implied, of GRNET S.A.
import logging import logging
from datetime import datetime
from dateutil.relativedelta import relativedelta
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.core.mail import send_mail, get_connection from django.core.mail import send_mail, get_connection
...@@ -690,6 +692,35 @@ def membership_allowed_actions(membership, request_user): ...@@ -690,6 +692,35 @@ def membership_allowed_actions(membership, request_user):
return allowed return allowed
def make_base_project(username):
chain = new_chain()
proj = create_project(
id=chain.chain,
last_application=None,
owner=None,
realname="tmp",
homepage="",
description=("base project for user " + username),
end_date=(datetime.now() + relativedelta(years=100)),
member_join_policy=CLOSED_POLICY,
member_leave_policy=CLOSED_POLICY,
limit_on_members_number=1,
private=True,
is_base=True)
proj.realname = "base:" + proj.uuid
proj.save()
# No quota are set; they will be filled in upon user acceptance
return proj
def enable_base_project(user):
project = user.base_project
_fill_from_skeleton(project)
project.activate()
new_membership(project, user, enroll=True)
quotas.qh_sync_project(project)
def submit_application(owner=None, def submit_application(owner=None,
name=None, name=None,
project_id=None, project_id=None,
...@@ -934,6 +965,7 @@ def approve_application(application_id, project_id=None, request_user=None, ...@@ -934,6 +965,7 @@ def approve_application(application_id, project_id=None, request_user=None,
quotas.qh_sync_locked_users(members) quotas.qh_sync_locked_users(members)
logger.info("%s has been approved." % (application.log_display)) logger.info("%s has been approved." % (application.log_display))
project_notif.application_notify(application, "approve") project_notif.application_notify(application, "approve")
return project
def _fill_from_skeleton(project): def _fill_from_skeleton(project):
......
...@@ -68,6 +68,7 @@ INSTALL_REQUIRES = [ ...@@ -68,6 +68,7 @@ INSTALL_REQUIRES = [
'Django>=1.4, <1.5', 'Django>=1.4, <1.5',
'South>=0.7.3', 'South>=0.7.3',
'httplib2>=0.6.0', 'httplib2>=0.6.0',
'python-dateutil>=1.4.1',
'snf-common', 'snf-common',
'django-tables2', 'django-tables2',
'recaptcha-client>=1.0.5', 'recaptcha-client>=1.0.5',
......
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