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
from astakos.im import settings
from astakos.im import forms
from astakos.im.quotas import qh_sync_new_user
import astakos.im.messages as astakos_messages
import datetime
......@@ -255,7 +253,7 @@ class ActivationBackend(object):
default=lambda obj:
str(obj))
user.save()
qh_sync_new_user(user)
functions.enable_base_project(user)
if user.is_rejected:
logger.warning("User has previously been "
......
......@@ -31,9 +31,9 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
import uuid
import datetime
from astakos.im import models
from astakos.im import functions
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.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.save()
......
......@@ -32,6 +32,8 @@
# or implied, of GRNET S.A.
import logging
from datetime import datetime
from dateutil.relativedelta import relativedelta
from django.utils.translation import ugettext as _
from django.core.mail import send_mail, get_connection
......@@ -690,6 +692,35 @@ def membership_allowed_actions(membership, request_user):
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,
name=None,
project_id=None,
......@@ -934,6 +965,7 @@ def approve_application(application_id, project_id=None, request_user=None,
quotas.qh_sync_locked_users(members)
logger.info("%s has been approved." % (application.log_display))
project_notif.application_notify(application, "approve")
return project
def _fill_from_skeleton(project):
......
......@@ -68,6 +68,7 @@ INSTALL_REQUIRES = [
'Django>=1.4, <1.5',
'South>=0.7.3',
'httplib2>=0.6.0',
'python-dateutil>=1.4.1',
'snf-common',
'django-tables2',
'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