Esempio n. 1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self._topics = ControlMultipleSelection('Topics')
        self._subjects = ControlMultipleSelection('Subjects')
        self._refresh_btn = ControlButton('<i class="filter icon"></i> Filter',
                                          default=self.render_html,
                                          label_visible=False)
        self._mytopics_btn = ControlButton(
            '<i class="plus icon"></i><i class="certificate icon"></i> Add my topics',
            default=self.__add_mytopics,
            css='basic',
            label_visible=False)
        self._htmlcontrol = ControlTemplate(
            'Timeline', template='timeline/funding-opportunities.html')

        self.formset = [('_topics', '_subjects'),
                        no_columns('_mytopics_btn', '_refresh_btn'),
                        '_htmlcontrol']

        self.__load_topics()
        self.__load_subjects()

        self.render_html(False)

        request = PyFormsMiddleware.get_request()
        self.fund_id = request.GET.get('fund', None)
Esempio n. 2
0
 def mark_to_update_client(self):
     self._update_client = True
     
     request = PyFormsMiddleware.get_request()
     if  self.parent is not None and \
         request is not None and \
         hasattr(request,'updated_apps'):
         request.updated_apps.add_top(self.parent)
Esempio n. 3
0
 def mark_to_update_client(self):
     """
     Mark the control to update in the client side.
     """
     self._update_client = True
     
     request = PyFormsMiddleware.get_request()
     if  self.parent is not None and \
         request is not None and \
         hasattr(request,'updated_apps'):
         request.updated_apps.add_top(self.parent)
Esempio n. 4
0
    def model_object(self):
        """
        django.db.models.Model object: Return the current object in edition.
        """

        if self.object_pk is None:
            return None
        else:
            queryset = self.model.objects.all()

            # check if the model has a query_set function
            # if so use it to get the data for visualization
            if hasattr(self.model, 'get_queryset'):
                request = PyFormsMiddleware.get_request()
                queryset = self.model.get_queryset(request, queryset)

            return queryset.get(pk=self.object_pk)
Esempio n. 5
0
    def __get_queryset(self):
        """
        
        """
        queryset = self.model.objects.all()

        #used to filter the model for inline fields
        if self.parent_field: 
            queryset = queryset.filter(**{self.parent_field.name: self.parent_pk})

        # check if the model has a query_set function
        # if so use it to get the data for visualization
        request  = PyFormsMiddleware.get_request()

        if hasattr(self.model, 'get_queryset'):
            queryset = self.model.get_queryset(request, queryset)
        
        return self.get_queryset(request, queryset)
Esempio n. 6
0
    def populate_table(self):
        request = PyFormsMiddleware.get_request()
        self._directory.value = request.GET.get('p', self._directory.value)
        #storage    = conf.MAESTRO_STORAGE_MANAGER.get(request.user)
        path = self._directory.value

        files = []
        for index, filename in enumerate(os.listdir(path)):
            filepath = os.path.join(path, filename)
            is_dir = os.path.isdir(filepath)
            filetype = ''
            filesize = 0
            if not is_dir:
                _, filetype = os.path.splitext(filename)
                filetype = filetype[1:]
                filesize = os.path.getsize(filepath)

            if self._only_folders.value and not is_dir: continue

            link = ''
            function = ''
            if is_dir:
                #function = 'javascript:add_file2control("{1}", "{0}");'.format(f.fullpath, self._control_id.value)
                link = """<a target='_blank' href='{0}' ><i class='selected radio icon' ></id></a>""".format(
                    function)

            if self._only_folders.value:
                #function = 'javascript:add_file2control("{1}", "{0}");'.format(f.fullpath, self._control_id.value)
                link = """<a target='_blank' href='{0}' ><i class='selected radio icon' ></id></a>""".format(
                    function)

            files.append([
                "<i class='folder icon' ></id>"
                if is_dir else "<i class='file outline icon' ></id>",
                filename,
                filetype,
                '' if is_dir else sizeof_fmt(filesize),
            ])

        self._files_table.value = ([['', '..', 'dir']] if path != '/' else
                                   []) + sorted(files,
                                                key=lambda a: (a[2], a[1]))