Пример #1
0
def get_common_dict(request, title, **kwargs):

    d = dict(title=title, IS_LOGGED_IN=False, SITE_URL=get_site_url())

    # Add other arguments
    for k, v in kwargs.items():
        d[k] = v

    if request.user.is_authenticated():
        d[USERNAME_KEY] = request.user.username
        d[IS_LOGGED_IN_KEY] = True
        d['my_dataset_count'] = get_dataset_count(request)
        d[IS_ACTIVE_STAFF] = request.user.is_active and request.user.is_staff

    return d
Пример #2
0
def get_common_dict(request, title, **kwargs):


    d = dict(title=title,
             IS_LOGGED_IN=False,
             SITE_URL=get_site_url())

    # Add other arguments
    for k, v in kwargs.items():
        d[k] = v

    if request.user.is_authenticated():
        d[USERNAME_KEY] = request.user.username
        d[IS_LOGGED_IN_KEY] = True
        d['my_dataset_count'] = get_dataset_count(request)
        d[IS_ACTIVE_STAFF] = request.user.is_active and request.user.is_staff

    return d
Пример #3
0
    def get_script_args_json(self, run_md5, as_list=False):

        site_url = get_site_url()

        url_to_dataset = reverse('admin:predict_predictdataset_change', args=(self.id,))
        admin_url = '{0}{1}'.format(site_url, url_to_dataset)
        callback_url = '{0}{1}'.format(site_url, reverse('view_dataset_run_notification', kwargs={}))

        d = dict(file_directory=self.file_directory,
                 dataset_id=self.id,
                 callback_url=callback_url,
                 user_email=self.user.user.email,
                 admin_url=admin_url,
                 run_md5=run_md5
                 )

        if as_list:
            return [ json.dumps(d)]
            #return [ '\'%s\'' % json.dumps(d)]
        return json.dumps(d)
Пример #4
0
    def get_dropbox_retrieval_script_params(self):
        assert self.id is not None, "This function cannot be called for an unsaved object.  (The id field is required)"

        callback_url = '{0}{1}'.format(get_site_url(),
                                reverse('record_file_retrieval_results', args=()))

        params = dict(dropbox_url=self.dataset.dropbox_url,
                destination_directory=self.dataset.file_directory,
                callback_url=callback_url,
                callback_md5=self.md5)

        print 'params', params

        f = DropboxRetrievalParamsForm(params)
        if f.is_valid():
            return f.cleaned_data


        logger.severe("Failed to create dropbox retrieve params for dataset id {0}. Errors from form: {1}".format(self.id, f.errors.items()))
        # Log a major error
        raise KeyError(f.errors)