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

astakos: Remove invitation management commands

Also add a notice in docs that inviting is currently disabled.
parent ed163a44
......@@ -878,8 +878,6 @@ Name Description
============================ ===========================
fix-superusers Transform superusers created by syncdb into AstakosUser instances
cleanup-full Cleanup sessions and session catalog
invitation-list List invitation
invitation-show Show invitation details
project-control Manage projects and applications
project-list List projects
project-show Show project details
......@@ -904,7 +902,6 @@ authpolicy-set Assign an existing authentication provider policy
authpolicy-show Show authentication provider profile details
group-add Create a group with the given name
group-list List available groups
user-invite Invite somebody
user-list List users
user-modify Modify user
user-show Show user details
......
......@@ -55,6 +55,10 @@ registration cases are illustrated in :ref:`registration-flow-label`
Invited user
~~~~~~~~~~~~
.. note::
Invitation feature is currently disabled.
A registered ~okeanos user, invites student Alice to subscribe to ~okeanos
services. Alice receives an email and through a link is navigated to Astakos's
signup page. The system prompts her to select one of the available
......
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from astakos.im.models import Invitation
from synnefo.webproject.management.commands import ListCommand
class Command(ListCommand):
help = "List invitations"
object_class = Invitation
FIELDS = {
"id": ("id", "The ID of the invitation"),
"inviter": ("inviter.username", "The inviter of the invitation"),
"username": ("username", "The receiver username"),
"realname": ("realname", "The receiver name"),
"code": ("code", "The code of the invitation"),
"is_consumed": ("is_consumed", "Whether the invitation is consumed or not"),
}
fields = ["id", "inviter", "username", "realname", "code", "is_consumed"]
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import CommandError
from astakos.im.models import Invitation
from synnefo.webproject.management.commands import SynnefoCommand
from synnefo.webproject.management import utils
class Command(SynnefoCommand):
args = "<invitation ID or code>"
help = "Show invitation info"
def handle(self, *args, **options):
if len(args) != 1:
raise CommandError("Please provide an invitation id")
try:
invitation = Invitation.objects.get(id=int(args[0]))
except Invitation.DoesNotExist:
try:
invitation = Invitation.objects.get(code=args[0])
except Invitation.DoesNotExist:
raise CommandError("Unknown invitation id '%s'" % (args[0],))
kv = {
'id': invitation.id,
'real name': invitation.realname,
'email': invitation.username,
'code': invitation.code,
'consumed': invitation.is_consumed,
'date created': invitation.created,
'date consumed': invitation.consumed,
'inviter real name': invitation.inviter.realname,
'invitater email': invitation.inviter.email,
}
utils.pprint_table(self.stdout, [kv.values()], kv.keys(),
options["output_format"], vertical=True)
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import BaseCommand, CommandError
from django.db.utils import IntegrityError
from django.db import transaction
from ._common import get_user
@transaction.commit_manually
class Command(BaseCommand):
args = "<inviter id or email> <email> <real name>"
help = "Invite a user"
def handle(self, *args, **options):
if len(args) != 3:
raise CommandError("Invalid number of arguments")
inviter = get_user(args[0], is_active=True)
if not inviter:
raise CommandError("Unknown inviter")
if not inviter.is_active:
raise CommandError("Inactive inviter")
if inviter.invitations > 0:
email = args[1]
realname = args[2]
try:
inviter.invite(email, realname)
self.stdout.write("Invitation sent to '%s'\n" % (email,))
except IntegrityError:
transaction.rollback()
raise CommandError(
"There is already an invitation for %s" % (email,))
else:
transaction.commit()
else:
raise CommandError("No invitations left")
......@@ -102,8 +102,6 @@ class Command(SynnefoCommand):
('last update', user.updated),
#('token', user.auth_token),
('token expiration', user.auth_token_expires),
('invitations', user.invitations),
('invitation level', user.level),
('providers', user.auth_providers_display),
('verified', user.is_verified),
('groups', [elem.name for elem in user.groups.all()]),
......
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