root / snf-astakos-app / astakos / im / project_error.py @ 9cdb86fd
History | View | Annotate | Download (2.3 kB)
1 | 8a8578c5 | Giorgos Korfiatis | # Copyright 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 8a8578c5 | Giorgos Korfiatis | #
|
3 | 8a8578c5 | Giorgos Korfiatis | # Redistribution and use in source and binary forms, with or
|
4 | 8a8578c5 | Giorgos Korfiatis | # without modification, are permitted provided that the following
|
5 | 8a8578c5 | Giorgos Korfiatis | # conditions are met:
|
6 | 8a8578c5 | Giorgos Korfiatis | #
|
7 | 8a8578c5 | Giorgos Korfiatis | # 1. Redistributions of source code must retain the above
|
8 | 8a8578c5 | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
9 | 8a8578c5 | Giorgos Korfiatis | # disclaimer.
|
10 | 8a8578c5 | Giorgos Korfiatis | #
|
11 | 8a8578c5 | Giorgos Korfiatis | # 2. Redistributions in binary form must reproduce the above
|
12 | 8a8578c5 | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
13 | 8a8578c5 | Giorgos Korfiatis | # disclaimer in the documentation and/or other materials
|
14 | 8a8578c5 | Giorgos Korfiatis | # provided with the distribution.
|
15 | 8a8578c5 | Giorgos Korfiatis | #
|
16 | 8a8578c5 | Giorgos Korfiatis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 8a8578c5 | Giorgos Korfiatis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 8a8578c5 | Giorgos Korfiatis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 8a8578c5 | Giorgos Korfiatis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 8a8578c5 | Giorgos Korfiatis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 8a8578c5 | Giorgos Korfiatis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 8a8578c5 | Giorgos Korfiatis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 8a8578c5 | Giorgos Korfiatis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 8a8578c5 | Giorgos Korfiatis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 8a8578c5 | Giorgos Korfiatis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 8a8578c5 | Giorgos Korfiatis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 8a8578c5 | Giorgos Korfiatis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 8a8578c5 | Giorgos Korfiatis | #
|
29 | 8a8578c5 | Giorgos Korfiatis | # The views and conclusions contained in the software and
|
30 | 8a8578c5 | Giorgos Korfiatis | # documentation are those of the authors and should not be
|
31 | 8a8578c5 | Giorgos Korfiatis | # interpreted as representing official policies, either expressed
|
32 | 8a8578c5 | Giorgos Korfiatis | # or implied, of GRNET S.A.
|
33 | 8a8578c5 | Giorgos Korfiatis | |
34 | 8a8578c5 | Giorgos Korfiatis | from django.http import HttpRequest |
35 | 8a8578c5 | Giorgos Korfiatis | from django.core.urlresolvers import reverse |
36 | 8a8578c5 | Giorgos Korfiatis | from django.contrib import messages |
37 | 8a8578c5 | Giorgos Korfiatis | from django.shortcuts import redirect |
38 | 8a8578c5 | Giorgos Korfiatis | from django.utils.translation import ugettext as _ |
39 | 8a8578c5 | Giorgos Korfiatis | from astakos.im.util import restrict_next |
40 | 8a8578c5 | Giorgos Korfiatis | from astakos.im.settings import COOKIE_DOMAIN |
41 | 8a8578c5 | Giorgos Korfiatis | import astakos.im.messages as astakos_messages |
42 | 8a8578c5 | Giorgos Korfiatis | |
43 | 8a8578c5 | Giorgos Korfiatis | def project_error_view(*args, **kwargs): |
44 | 8a8578c5 | Giorgos Korfiatis | if not args: |
45 | 8a8578c5 | Giorgos Korfiatis | m = "need a request as first argument"
|
46 | 8a8578c5 | Giorgos Korfiatis | raise AssertionError(m) |
47 | 8a8578c5 | Giorgos Korfiatis | |
48 | 8a8578c5 | Giorgos Korfiatis | request = args[0]
|
49 | 8a8578c5 | Giorgos Korfiatis | if not isinstance(request, HttpRequest): |
50 | 8a8578c5 | Giorgos Korfiatis | m = "need a request as first argument"
|
51 | 8a8578c5 | Giorgos Korfiatis | raise AssertionError(m) |
52 | 8a8578c5 | Giorgos Korfiatis | |
53 | 8a8578c5 | Giorgos Korfiatis | next = reverse('astakos.im.views.project_list')
|
54 | 8a8578c5 | Giorgos Korfiatis | m = _(astakos_messages.GENERIC_ERROR) |
55 | 8a8578c5 | Giorgos Korfiatis | messages.error(request, m) |
56 | 8a8578c5 | Giorgos Korfiatis | next = restrict_next(next, domain=COOKIE_DOMAIN)
|
57 | 8a8578c5 | Giorgos Korfiatis | return redirect(next) |