+@never_cache
+def selectinst(request):
+ if request.method == 'POST':
+ request_data = request.POST.copy()
+ user = request_data['user']
+ try:
+ existingProfile = UserProfile.objects.get(user=user)
+ error = _("Violation warning: User account is already associated with an institution.The event has been logged and our administrators will be notified about it")
+ return render_to_response('error.html', {'error': error, 'inactive': True},
+ context_instance=RequestContext(request))
+ except UserProfile.DoesNotExist:
+ pass
+
+ form = UserProfileForm(request_data)
+ if form.is_valid():
+ userprofile = form.save()
+ user_activation_notify(userprofile.user)
+ error = _("User account <strong>%s</strong> is pending activation. Administrators have been notified and will activate this account within the next days. <br>If this account has remained inactive for a long time contact your technical coordinator or GRNET Helpdesk") %userprofile.user.username
+ return render_to_response('error.html', {'error': error, 'inactive': True},
+ context_instance=RequestContext(request))
+ else:
+ form.fields['user'] = forms.ModelChoiceField(queryset=User.objects.filter(pk=user.pk), empty_label=None)
+ form.fields['institution'] = forms.ModelChoiceField(queryset=Peer.objects.all(), empty_label=None)
+ return render_to_response('registration/select_institution.html', {'form': form}, context_instance=RequestContext(request))
+
+@never_cache
+def overview(request):
+ user = request.user
+ if user.is_authenticated():
+ if user.has_perm('accounts.overview'):
+ users = User.objects.all()
+ group_routes = Route.objects.all()
+ return render_to_response('overview/index.html', {'users': users, 'routes': group_routes},
+ context_instance=RequestContext(request))
+ else:
+ violation=True
+ return render_to_response('overview/index.html', {'violation': violation},
+ context_instance=RequestContext(request))
+ else:
+ return HttpResponseRedirect(reverse("altlogin"))
+