Exemple #1
0
    def get_context_data(self):
        """
        Returns the context to render the view. Overwrites the method to add
        projects, projects status types and extensions to context

        Return
        dict
        """
        projects = Project.objects.get_list(self.request.user)

        from geokey.extensions.base import extensions
        ext = []
        for ext_id in extensions.keys():
            extension = extensions.get(ext_id)

            if extension.get('display_admin') and (
                    not extension.get('superuser') or
                    self.request.user.is_superuser):
                ext.append(extension)

        return {
            'admin_projects': projects.filter(admins=self.request.user),
            'involved_projects': projects.exclude(
                admins=self.request.user).exists(),
            'status_types': STATUS,
            'extensions': ext
        }
Exemple #2
0
    def get_context_data(self):
        """
        Return the context to render the view.

        Overwrite the method to add projects, project status types and
        extensions to the context.

        Returns
        -------
        dict
        """
        from geokey.extensions.base import extensions

        ext = []
        for ext_id in sorted(extensions):
            extension = extensions.get(ext_id)
            if extension.get('display_admin') and (
                    not extension.get('superuser') or
                    self.request.user.is_superuser):
                ext.append(extension)

        return {
            'projects': Project.objects.get_list(
                self.request.user).filter(admins=self.request.user),
            'status_types': STATUS,
            'extensions': ext
        }
Exemple #3
0
 def test(self):
     register('text_ext', 'Test', True)
     extension = ext.get('text_ext')
     self.assertEqual(extension.get('ext_id'), 'text_ext')
     self.assertEqual(extension.get('name'), 'Test')
     self.assertEqual(extension.get('index_url'), 'text_ext:index')
     self.assertTrue(extension.get('display_admin'))
Exemple #4
0
 def test(self):
     register('text_ext', 'Test', True)
     extension = ext.get('text_ext')
     self.assertEqual(extension.get('ext_id'), 'text_ext')
     self.assertEqual(extension.get('name'), 'Test')
     self.assertEqual(extension.get('index_url'), 'text_ext:index')
     self.assertTrue(extension.get('display_admin'))
Exemple #5
0
    def test_register(self):
        """Test registering new extension."""
        self.ext_id = 'test_ext'
        register(self.ext_id, 'Test', True, True, '1.0.0')

        extension = extensions.get(self.ext_id)
        self.assertEqual(extension.get('ext_id'), self.ext_id)
        self.assertEqual(extension.get('name'), 'Test')
        self.assertEqual(extension.get('version'), '1.0.0')
        self.assertTrue(extension.get('display_admin'))
        self.assertTrue(extension.get('superuser'))
        self.assertEqual(extension.get('index_url'), self.ext_id + ':index')
Exemple #6
0
    def test_register(self):
        """Test registering new extension."""
        self.ext_id = 'test_ext'
        register(self.ext_id, 'Test', True, True, '1.0.0')

        extension = extensions.get(self.ext_id)
        self.assertEqual(extension.get('ext_id'), self.ext_id)
        self.assertEqual(extension.get('name'), 'Test')
        self.assertEqual(extension.get('version'), '1.0.0')
        self.assertTrue(extension.get('display_admin'))
        self.assertTrue(extension.get('superuser'))
        self.assertEqual(extension.get('index_url'), self.ext_id + ':index')
Exemple #7
0
 def test_exiting(self):
     ext['text_ext'] = {
         'ext_id': 'text_ext',
         'name': 'Test',
         'display_admin': True,
         'index_url': 'text_ext:index'
     }
     try:
         register('text_ext', 'Test Name', False)
     except ExtensionExists:
         extension = ext.get('text_ext')
         self.assertEqual(extension.get('ext_id'), 'text_ext')
         self.assertEqual(extension.get('name'), 'Test')
         self.assertEqual(extension.get('index_url'), 'text_ext:index')
         self.assertTrue(extension.get('display_admin'))
     else:
         self.fail('ExtensionExists not raised')
Exemple #8
0
 def test_exiting(self):
     ext['text_ext'] = {
         'ext_id': 'text_ext',
         'name': 'Test',
         'display_admin': True,
         'index_url': 'text_ext:index'
     }
     try:
         register('text_ext', 'Test Name', False)
     except ExtensionExists:
         extension = ext.get('text_ext')
         self.assertEqual(extension.get('ext_id'), 'text_ext')
         self.assertEqual(extension.get('name'), 'Test')
         self.assertEqual(
             extension.get('index_url'),
             'text_ext:index'
         )
         self.assertTrue(extension.get('display_admin'))
     else:
         self.fail('ExtensionExists not raised')