root / snf-astakos-app / astakos / im / management / commands / project-deny.py @ e84332a3
History | View | Annotate | Download (2.3 kB)
1 | 19eb3ee6 | Giorgos Korfiatis | # Copyright 2012 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 19eb3ee6 | Giorgos Korfiatis | #
|
3 | 19eb3ee6 | Giorgos Korfiatis | # Redistribution and use in source and binary forms, with or
|
4 | 19eb3ee6 | Giorgos Korfiatis | # without modification, are permitted provided that the following
|
5 | 19eb3ee6 | Giorgos Korfiatis | # conditions are met:
|
6 | 19eb3ee6 | Giorgos Korfiatis | #
|
7 | 19eb3ee6 | Giorgos Korfiatis | # 1. Redistributions of source code must retain the above
|
8 | 19eb3ee6 | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
9 | 19eb3ee6 | Giorgos Korfiatis | # disclaimer.
|
10 | 19eb3ee6 | Giorgos Korfiatis | #
|
11 | 19eb3ee6 | Giorgos Korfiatis | # 2. Redistributions in binary form must reproduce the above
|
12 | 19eb3ee6 | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
13 | 19eb3ee6 | Giorgos Korfiatis | # disclaimer in the documentation and/or other materials
|
14 | 19eb3ee6 | Giorgos Korfiatis | # provided with the distribution.
|
15 | 19eb3ee6 | Giorgos Korfiatis | #
|
16 | 19eb3ee6 | Giorgos Korfiatis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 19eb3ee6 | Giorgos Korfiatis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 19eb3ee6 | Giorgos Korfiatis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 19eb3ee6 | Giorgos Korfiatis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 19eb3ee6 | Giorgos Korfiatis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 19eb3ee6 | Giorgos Korfiatis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 19eb3ee6 | Giorgos Korfiatis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 19eb3ee6 | Giorgos Korfiatis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 19eb3ee6 | Giorgos Korfiatis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 19eb3ee6 | Giorgos Korfiatis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 19eb3ee6 | Giorgos Korfiatis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 19eb3ee6 | Giorgos Korfiatis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 19eb3ee6 | Giorgos Korfiatis | #
|
29 | 19eb3ee6 | Giorgos Korfiatis | # The views and conclusions contained in the software and
|
30 | 19eb3ee6 | Giorgos Korfiatis | # documentation are those of the authors and should not be
|
31 | 19eb3ee6 | Giorgos Korfiatis | # interpreted as representing official policies, either expressed
|
32 | 19eb3ee6 | Giorgos Korfiatis | # or implied, of GRNET S.A.
|
33 | 19eb3ee6 | Giorgos Korfiatis | |
34 | 19eb3ee6 | Giorgos Korfiatis | from optparse import make_option |
35 | 19eb3ee6 | Giorgos Korfiatis | |
36 | 19eb3ee6 | Giorgos Korfiatis | from django.core.management.base import BaseCommand, CommandError |
37 | 19eb3ee6 | Giorgos Korfiatis | from django.core.exceptions import PermissionDenied |
38 | 19eb3ee6 | Giorgos Korfiatis | from django.db import transaction |
39 | 19eb3ee6 | Giorgos Korfiatis | |
40 | 19eb3ee6 | Giorgos Korfiatis | from astakos.im.models import ProjectApplication |
41 | 19eb3ee6 | Giorgos Korfiatis | from astakos.im.functions import deny_application |
42 | 19eb3ee6 | Giorgos Korfiatis | |
43 | 19eb3ee6 | Giorgos Korfiatis | class Command(BaseCommand): |
44 | 19eb3ee6 | Giorgos Korfiatis | args = "<project application id>"
|
45 | 19eb3ee6 | Giorgos Korfiatis | help = "Deny a project application"
|
46 | 19eb3ee6 | Giorgos Korfiatis | |
47 | 19eb3ee6 | Giorgos Korfiatis | @transaction.commit_on_success
|
48 | 19eb3ee6 | Giorgos Korfiatis | def handle(self, *args, **options): |
49 | 19eb3ee6 | Giorgos Korfiatis | if len(args) < 1: |
50 | 19eb3ee6 | Giorgos Korfiatis | raise CommandError("Please provide an application identifier") |
51 | 19eb3ee6 | Giorgos Korfiatis | try:
|
52 | 19eb3ee6 | Giorgos Korfiatis | app_id = int(args[0]) |
53 | 19eb3ee6 | Giorgos Korfiatis | except ValueError: |
54 | 19eb3ee6 | Giorgos Korfiatis | raise CommandError('Invalid id') |
55 | 19eb3ee6 | Giorgos Korfiatis | else:
|
56 | 19eb3ee6 | Giorgos Korfiatis | try:
|
57 | 19eb3ee6 | Giorgos Korfiatis | deny_application(app_id) |
58 | 19eb3ee6 | Giorgos Korfiatis | except (PermissionDenied, IOError): |
59 | 19eb3ee6 | Giorgos Korfiatis | raise CommandError('Invalid id') |