fix: hide management section for non pi users
authorYasin <mohammed-yasin.rahman@lip6.fr>
Thu, 3 Jul 2014 17:08:15 +0000 (19:08 +0200)
committerYasin <mohammed-yasin.rahman@lip6.fr>
Thu, 3 Jul 2014 17:08:15 +0000 (19:08 +0200)
portal/accountview.py
portal/contactview.py
portal/forms.py
portal/homeview.py
portal/slicerequestview.py
portal/sliceresourceview.py
portal/supportview.py
portal/validationview.py

index 15c3799..c88ac0e 100644 (file)
@@ -199,7 +199,7 @@ class AccountView(LoginRequiredAutoLogoutView, ThemeView):
                         if 'myslice' in platform_detail['platform']:
                             acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
         # assigning values
-        if acc_auth_cred == {}:
+        if acc_auth_cred == {} or acc_auth_cred == 'N/A':
             pi = "is_not_pi"
         else:
             pi = "is_pi"
index c985b29..c41ee74 100644 (file)
@@ -35,7 +35,7 @@ class ContactView (FreeAccessView, ThemeView):
             #theme.template_name = 'email_support.txt'
             #recipients = render_to_string(theme.template, form.cleaned_data)
             #recipients = subject.replace('\n', '')
-            recipients = ['support@myslice.info','contact@fed4fire.eu']
+            recipients = ['support@myslice.info']
             if cc_myself:
                 recipients.append(email)
             #recipients = ['support@myslice.info']
@@ -89,7 +89,7 @@ class ContactView (FreeAccessView, ThemeView):
                             if 'myslice' in platform_detail['platform']:
                                 acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
             # assigning values
-            if acc_auth_cred == {}:
+            if acc_auth_cred == {} or acc_auth_cred == 'N/A':
                 pi = "is_not_pi"
             else:
                 pi = "is_pi"
index ecd2e6c..683cffb 100644 (file)
@@ -99,7 +99,7 @@ class ContactForm(forms.Form):
 class PassResetForm(forms.Form):
     email = forms.EmailField(widget=forms.TextInput(attrs={'class':'form-control'}))
 
-class SliceRequestForm(forms.Form):
+#class SliceRequestForm(forms.Form):
 #    slice_name = forms.CharField()
 #    authority_hrn = forms.ChoiceField(choices=[(1, 'un')])
 #    number_of_nodes  = forms.DecimalField()
@@ -107,52 +107,52 @@ class SliceRequestForm(forms.Form):
 #    purpose = forms.CharField(widget=forms.Textarea)
 #    email = forms.EmailField()
 #    cc_myself = forms.BooleanField(required=False)
-
-    slice_name = forms.CharField(
-        widget=forms.TextInput(attrs={'class':'form-control'}), 
-        help_text="The name for the slice you wish to create")
-    authority_hrn = forms.ChoiceField(
-        widget    = forms.Select(attrs={'class':'form-control'}),
-        choices   = [],
-        help_text = "An authority responsible for vetting your slice")
-    number_of_nodes = forms.DecimalField(
-        widget    = forms.TextInput(attrs={'class':'form-control'}),
-        help_text = "The number of nodes you expect to request (informative)")
-    type_of_nodes = forms.CharField(
-        widget    = forms.TextInput(attrs={'class':'form-control'}),
-        help_text = "The type of nodes you expect to request (informative)")
-    purpose = forms.CharField(
-        widget    = forms.Textarea(attrs={'class':'form-control'}),
-        help_text = "The purpose of your experiment (informative)")
-    email = forms.EmailField(
-        widget    = forms.TextInput(attrs={'class':'form-control'}),
-        help_text = "Your email address")
-    cc_myself = forms.BooleanField(
-        widget    = forms.CheckboxInput(attrs={'class':'form-control'}),
-        required  = False,
-        help_text = "If you'd like to be cc'ed on the request email")
-
-    def __init__(self, *args, **kwargs):
-        initial =  kwargs.get('initial', {})
-        authority_hrn = initial.get('authority_hrn', None)
-
-        # set just the initial value
-        # in the real form needs something like this {'authority_hrn':'a'}
-        # but in this case you want {'authority_hrn':('a', 'letter_a')}
-        if authority_hrn:
-            kwargs['initial']['authority_hrn'] = authority_hrn[0]
-
-        # create the form
-        super(SliceRequestForm, self).__init__(*args, **kwargs)
-
-        # self.fields only exist after, so a double validation is needed
-        if authority_hrn:# and authority_hrn[0] not in (c[0] for c in authority_hrn):
-            # XXX This does not work, the choicefield is not updated...
-            #self.fields['authority_hrn'].choices.extend(authority_hrn)
-            self.fields['authority_hrn'] = forms.ChoiceField(
-                widget    = forms.Select(attrs={'class':'form-control'}),
-                choices   = authority_hrn,
-                help_text = "An authority responsible for vetting your slice")
+#
+#    slice_name = forms.CharField(
+#        widget=forms.TextInput(attrs={'class':'form-control'}), 
+#        help_text="The name for the slice you wish to create")
+#    authority_hrn = forms.ChoiceField(
+#        widget    = forms.Select(attrs={'class':'form-control'}),
+#        choices   = [],
+#        help_text = "An authority responsible for vetting your slice")
+#    number_of_nodes = forms.DecimalField(
+#        widget    = forms.TextInput(attrs={'class':'form-control'}),
+#        help_text = "The number of nodes you expect to request (informative)")
+#    type_of_nodes = forms.CharField(
+#        widget    = forms.TextInput(attrs={'class':'form-control'}),
+#        help_text = "The type of nodes you expect to request (informative)")
+#    purpose = forms.CharField(
+#        widget    = forms.Textarea(attrs={'class':'form-control'}),
+#        help_text = "The purpose of your experiment (informative)")
+#    email = forms.EmailField(
+#        widget    = forms.TextInput(attrs={'class':'form-control'}),
+#        help_text = "Your email address")
+#    cc_myself = forms.BooleanField(
+#        widget    = forms.CheckboxInput(attrs={'class':'form-control'}),
+#        required  = False,
+#        help_text = "If you'd like to be cc'ed on the request email")
+#
+#    def __init__(self, *args, **kwargs):
+#        initial =  kwargs.get('initial', {})
+#        authority_hrn = initial.get('authority_hrn', None)
+#
+#        # set just the initial value
+#        # in the real form needs something like this {'authority_hrn':'a'}
+#        # but in this case you want {'authority_hrn':('a', 'letter_a')}
+#        if authority_hrn:
+#            kwargs['initial']['authority_hrn'] = authority_hrn[0]
+#
+#        # create the form
+#        super(SliceRequestForm, self).__init__(*args, **kwargs)
+#
+#        # self.fields only exist after, so a double validation is needed
+#        if authority_hrn:# and authority_hrn[0] not in (c[0] for c in authority_hrn):
+#            # XXX This does not work, the choicefield is not updated...
+#            #self.fields['authority_hrn'].choices.extend(authority_hrn)
+#            self.fields['authority_hrn'] = forms.ChoiceField(
+#                widget    = forms.Select(attrs={'class':'form-control'}),
+#                choices   = authority_hrn,
+#                help_text = "An authority responsible for vetting your slice")
 
 
 class PasswordResetForm(forms.Form):
index 029dc31..d46ed65 100644 (file)
@@ -75,7 +75,7 @@ class HomeView (FreeAccessView, ThemeView):
                                     if 'myslice' in platform_detail['platform']:
                                         acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
                     # assigning values
-                    if acc_auth_cred == {}:
+                    if acc_auth_cred=={} or acc_auth_cred=='N/A':
                         pi = "is_not_pi"
                     else:
                         pi = "is_pi"
@@ -111,7 +111,7 @@ class HomeView (FreeAccessView, ThemeView):
                             if 'myslice' in platform_detail['platform']:
                                 acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
             # assigning values
-            if acc_auth_cred == {}:
+            if acc_auth_cred=={} or acc_auth_cred=='N/A':
                 pi = "is_not_pi"
             else:
                 pi = "is_pi"
index 5eb0725..bc8c203 100644 (file)
@@ -8,7 +8,7 @@ from manifold.core.query        import Query
 from manifoldapi.manifoldapi    import execute_admin_query, execute_query
 
 from portal.actions             import is_pi, create_slice, create_pending_slice
-from portal.forms               import SliceRequestForm
+#from portal.forms               import SliceRequestForm
 from unfold.loginrequired       import LoginRequiredAutoLogoutView
 from ui.topmenu                 import topmenu_items_live, the_user
 
@@ -62,7 +62,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
 
 
         # checking if pi or not
-        if acc_auth_cred == {}:
+        if acc_auth_cred == {} or acc_auth_cred == 'N/A':
             pi = "is_not_pi"
         else:
             pi = "is_pi"
index 749f739..f6d29db 100644 (file)
@@ -250,7 +250,7 @@ class SliceResourceView (LoginRequiredView, ThemeView):
                         if 'myslice' in platform_detail['platform']:
                             acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
         # assigning values
-        if acc_auth_cred == {}:
+        if acc_auth_cred == {} or acc_auth_cred == 'N/A':
             pi = "is_not_pi"
         else:
             pi = "is_pi"
index f97705d..80653e8 100644 (file)
@@ -44,7 +44,7 @@ class SupportView (FreeAccessView, ThemeView):
                             if 'myslice' in platform_detail['platform']:
                                 acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
             # assigning values
-            if acc_auth_cred == {}:
+            if acc_auth_cred == {} or acc_auth_cred == 'N/A':
                 pi = "is_not_pi"
             else:
                 pi = "is_pi"
index b8454f0..b26ba0f 100644 (file)
@@ -260,6 +260,8 @@ class ValidatePendingView(LoginRequiredAutoLogoutView, ThemeView):
                 dest[auth_hrn].append(request)
         
         context = super(ValidatePendingView, self).get_context_data(**kwargs)
+        print "testing"
+        print ctx_my_authorities
         context['my_authorities']   = ctx_my_authorities
         context['sub_authorities']   = ctx_sub_authorities
         context['delegation_authorities'] = ctx_delegation_authorities