Scheduler2 plugin: Queries handled by the plugin = query (resource in slice), query_l...
[unfold.git] / portal / emailactivationview.py
1 from unfold.loginrequired               import FreeAccessView
2 #
3 from manifold.core.query                import Query
4 from manifoldapi.manifoldapi            import execute_query, execute_admin_query
5 from portal.actions                     import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user
6 #
7 from unfold.page                        import Page    
8 from ui.topmenu                         import topmenu_items_live, the_user
9 #
10 from django.http                        import HttpResponse, HttpResponseRedirect
11 from django.contrib                     import messages
12 from django.contrib.auth.decorators     import login_required
13 from myslice.theme                      import ThemeView
14 from portal.models                      import PendingUser
15 #
16 import json, os, re, itertools
17
18 # requires login
19 class ActivateEmailView(FreeAccessView, ThemeView):
20     template_name = "email_activation.html"
21     def dispatch(self, *args, **kwargs):
22         return super(ActivateEmailView, self).dispatch(*args, **kwargs)
23
24
25     def get_context_data(self, **kwargs):
26
27         page = Page(self.request)
28         #page.add_js_files  ( [ "js/jquery.validate.js", "js/my_account.register.js", "js/my_account.edit_profile.js" ] )
29         #page.add_css_files ( [ "css/onelab.css", "css/account_view.css","css/plugin.css" ] )
30
31         for key, value in kwargs.iteritems():
32             #print "%s = %s" % (key, value)
33             if key == "hash_code":
34                 hash_code=value
35        
36         if PendingUser.objects.filter(email_hash__iexact = hash_code):
37             #get_user = PendingUser.objects.filter(email_hash__iexact = hash_code)
38             #get_user.status= 'True'
39             #get_user.save()
40             PendingUser.objects.filter(email_hash__iexact = hash_code).update(status='True')
41             activation = 'success'
42         else:
43             activation = 'failed'
44
45         context = super(ActivateEmailView, self).get_context_data(**kwargs)
46         context['activation_status'] = activation
47         # XXX This is repeated in all pages
48         # more general variables expected in the template
49         context['title'] = 'Platforms connected to MySlice'
50         # the menu items on the top
51         context['topmenu_items'] = topmenu_items_live('My Account', page)
52         # so we can sho who is logged
53         context['username'] = the_user(self.request)
54         context['theme'] = self.theme
55 #        context ['firstname'] = config['firstname']
56         prelude_env = page.prelude_env()
57         context.update(prelude_env)
58         return context