Revision 279d6e51

b/snf-astakos-app/astakos/im/api/__init__.py
205 205
                   name="Usage"))
206 206
            append(item(
207 207
                   url=absolute(request, reverse('feedback')),
208
                   name="Feedback"))
208
                   name="Contact"))
209 209
#            append(item(
210 210
#                   url=absolute(request, reverse('billing')),
211 211
#                   name="Billing"))
b/snf-astakos-app/astakos/im/templates/im/astakosgroup_list.html
225 225
            {% with q|paginate:args as page_obj %}
226 226
        	 	{% if page_obj.object_list  %}
227 227
	      	    <div>
228
                    {% comment %}
229 228
					<form method="GET" class="minimal" action="#allGroups" id="mygroups">
230 229
						<div class="form-row">
231 230
						    <select name="sorting"  class="dropkicked"  tabindex="1">
......
238 237
							</select>
239 238
						</div>
240 239
					</form>
241
                    {% endcomment %}
242 240
					<table class="alt-style complex" id="allGroups">
243 241
			            <caption>MY PROJECTS</caption>
244 242
			            <thead>
b/snf-astakos-app/astakos/im/templatetags/astakos_tags.py
64 64
            context.render_context[self] = content
65 65

  
66 66
        return context.render_context[self]
67

  
68

  
69
@register.simple_tag
70
def olga(v):
71
    return v+'a'
b/snf-astakos-app/astakos/im/views.py
127 127
                for pkey, value in perms.iteritems():
128 128
                    attr = 'is_available_for_%s' % pkey.lower()
129 129
                    if getattr(provider, attr)() != value:
130
                        msg = provider.get_message("NOT_ACTIVE_FOR_" + pkey.upper())
131
                        messages.error(request, msg)
130
                        #TODO: add session message
132 131
                        return HttpResponseRedirect(reverse('login'))
133 132
            return func(request, *args)
134 133
        return wrapper
......
195 194
    if request.user.is_authenticated():
196 195
        return HttpResponseRedirect(reverse('astakos.im.views.edit_profile'))
197 196

  
198
    third_party_token = request.GET.get('key', False)
199
    if third_party_token:
200
        messages.info(request, astakos_messages.AUTH_PROVIDER_LOGIN_TO_ADD)
201

  
202 197
    return render_response(
203 198
        template_name,
204 199
        login_form = LoginForm(request=request),
......
367 362

  
368 363
@transaction.commit_manually
369 364
@require_http_methods(["GET", "POST"])
370
def signup(request, template_name='im/signup.html',
371
           on_success='im/signup_complete.html', extra_context=None,
372
           on_success_redirect='/im/profile/',
373
           backend=None):
365
def signup(request, template_name='im/signup.html', on_success='im/signup_complete.html', extra_context=None, backend=None):
374 366
    """
375 367
    Allows a user to create a local account.
376 368

  
......
410 402
        return HttpResponseRedirect(reverse('edit_profile'))
411 403

  
412 404
    provider = get_query(request).get('provider', 'local')
405
    if not auth_providers.get_provider(provider).is_available_for_create():
406
        raise PermissionDenied
407

  
413 408
    id = get_query(request).get('id')
414 409
    try:
415 410
        instance = AstakosUser.objects.get(id=id) if id else None
......
423 418
        provider = pending.provider
424 419
        instance = pending.get_user_instance()
425 420

  
426
    if not auth_providers.get_provider(provider).is_available_for_create():
427
        raise PermissionDenied
428

  
429 421
    try:
430 422
        if not backend:
431 423
            backend = get_backend(request)
......
433 425
    except Exception, e:
434 426
        form = SimpleBackend(request).get_signup_form(provider)
435 427
        messages.error(request, e)
436

  
437 428
    if request.method == 'POST':
438 429
        if form.is_valid():
439 430
            user = form.save(commit=False)
......
460 451
                    return response
461 452
                messages.add_message(request, status, message)
462 453
                transaction.commit()
463
                return HttpResponseRedirect(on_success_redirect)
464

  
454
                return render_response(
455
                    on_success,
456
                    context_instance=get_context(
457
                        request,
458
                        extra_context
459
                    )
460
                )
465 461
            except SendMailError, e:
466 462
                logger.exception(e)
467 463
                status = messages.ERROR
......
474 470
                messages.error(request, message)
475 471
                logger.exception(e)
476 472
                transaction.rollback()
477

  
478 473
    return render_response(template_name,
479 474
                           signup_form=form,
480 475
                           third_party_token=third_party_token,
......
584 579
    try:
585 580
        user = AstakosUser.objects.get(auth_token=token)
586 581
    except AstakosUser.DoesNotExist:
587
        messages.error(request, _(astakos_messages.ACCOUNT_UNKNOWN))
588
        return HttpResponseRedirect(reverse('index'))
582
        return HttpResponseBadRequest(_(astakos_messages.ACCOUNT_UNKNOWN))
589 583

  
590 584
    if user.is_active:
591 585
        message = _(astakos_messages.ACCOUNT_ALREADY_ACTIVE)
592 586
        messages.error(request, message)
593
        return HttpResponseRedirect(reverse('index'))
587
        return index(request)
594 588

  
595 589
    try:
596
        activate_func(user, greeting_email_template_name,
597
                      helpdesk_email_template_name, verify_email=True)
590
        activate_func(user, greeting_email_template_name, helpdesk_email_template_name, verify_email=True)
598 591
        response = prepare_response(request, user, next, renew=True)
599 592
        transaction.commit()
600
        messages.success(request, astakos_messages.ACCOUNT_ACTIVATED)
601
        return HttpResponseRedirect(reverse('edit_profile'))
593
        return response
602 594
    except SendMailError, e:
603 595
        message = e.message
604 596
        messages.add_message(request, messages.ERROR, message)
605 597
        transaction.rollback()
606
        return HttpResponseRedirect(reverse('index'))
598
        return index(request)
607 599
    except BaseException, e:
608 600
        status = messages.ERROR
609 601
        message = _(astakos_messages.GENERIC_ERROR)
610 602
        messages.add_message(request, messages.ERROR, message)
611 603
        logger.exception(e)
612 604
        transaction.rollback()
613
        return HttpResponseRedirect(reverse('index'))
605
        return index(request)
614 606

  
615 607

  
616 608
@require_http_methods(["GET", "POST"])
......
670 662
                 confirm_template_name='registration/email_change_done.html',
671 663
                 extra_context=None):
672 664
    extra_context = extra_context or {}
673

  
674

  
675 665
    if activation_key:
676 666
        try:
677 667
            user = EmailChange.objects.change_email(activation_key)
......
681 671
                auth_logout(request)
682 672
                response = prepare_response(request, user)
683 673
                transaction.commit()
684
                return HttpResponseRedirect(reverse('edit_profile'))
674
                return response
685 675
        except ValueError, e:
686 676
            messages.error(request, e)
687
            transaction.rollback()
688
            return HttpResponseRedirect(reverse('index'))
689

  
690 677
        return render_response(confirm_template_name,
691
                               modified_user=user if 'user' in locals() \
692
                               else None, context_instance=get_context(request,
678
                               modified_user=user if 'user' in locals(
679
                               ) else None,
680
                               context_instance=get_context(request,
693 681
                                                            extra_context))
694 682

  
695 683
    if not request.user.is_authenticated():
696 684
        path = quote(request.get_full_path())
697 685
        url = request.build_absolute_uri(reverse('index'))
698 686
        return HttpResponseRedirect(url + '?next=' + path)
699

  
700
    # clean up expired email changes
701
    if request.user.email_change_is_pending():
702
        change = request.user.emailchanges.get()
703
        if change.activation_key_expired():
704
            change.delete()
705
            transaction.commit()
706
            return HttpResponseRedirect(reverse('email_change'))
707

  
708 687
    form = EmailChangeForm(request.POST or None)
709 688
    if request.method == 'POST' and form.is_valid():
710 689
        try:
711
            # delete pending email changes
712
            request.user.emailchanges.all().delete()
713 690
            ec = form.save(email_template_name, request)
714 691
        except SendMailError, e:
715 692
            msg = e
716 693
            messages.error(request, msg)
717 694
            transaction.rollback()
718
            return HttpResponseRedirect(reverse('edit_profile'))
695
        except IntegrityError, e:
696
            msg = _(astakos_messages.PENDING_EMAIL_CHANGE_REQUEST)
697
            messages.error(request, msg)
719 698
        else:
720 699
            msg = _(astakos_messages.EMAIL_CHANGE_REGISTERED)
721 700
            messages.success(request, msg)
722 701
            transaction.commit()
723
            return HttpResponseRedirect(reverse('edit_profile'))
724

  
725
    if request.user.email_change_is_pending():
726
        messages.warning(request, astakos_messages.PENDING_EMAIL_CHANGE_REQUEST)
727

  
728 702
    return render_response(
729 703
        form_template_name,
730 704
        form=form,
......
734 708

  
735 709
def send_activation(request, user_id, template_name='im/login.html', extra_context=None):
736 710

  
737
    if request.user.is_authenticated():
738
        messages.error(request, 'You are already signed in.')
739
        return HttpResponseRedirect(reverse('edit_profile'))
740

  
741 711
    if settings.MODERATION_ENABLED:
742 712
        raise PermissionDenied
743 713

  
......
751 721
            send_activation_func(u)
752 722
            msg = _(astakos_messages.ACTIVATION_SENT)
753 723
            messages.success(request, msg)
754
            return HttpResponseRedirect('/im/')
755

  
756 724
        except SendMailError, e:
757 725
            messages.error(request, e)
758 726
    return render_response(
......
1509 1477
        template='im/how_it_works.html',
1510 1478
        context_instance=get_context(request),)
1511 1479

  
1512
def test(v):
1513
    res = 'foo'
1514
    return res
1480

  

Also available in: Unified diff