def display_job_result(self, req, form):
        """Displays the results of a job"""
        argd = wash_urlargd(form, {
                           "result_id": (int, JobResult.ID_MISSING),
                           "output_format" : (int, Job.OUTPUT_FORMAT_MISSING)
                           })
        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)
        job_result_id = argd["result_id"]
        output_format = argd["output_format"]

        title = _("Export Job Result")
        try:
            body = perform_request_display_job_result(job_result_id = job_result_id,
                                                      output_format = output_format,
                                                      user_id = user_id,
                                                      language = language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title = title,
                    metaheaderadd = get_css(),
                    body = body,
                    req = req,
                    navmenuid   = "fieldexporter",
                    titleprologue = get_navigation_menu(language),
                    navtrail = self._NAVTRAIL_EXPORT,
                    language = language)
Exemple #2
0
    def display_job_result(self, req, form):
        """Displays the results of a job"""
        argd = wash_urlargd(
            form, {
                "result_id": (int, JobResult.ID_MISSING),
                "output_format": (int, Job.OUTPUT_FORMAT_MISSING)
            })
        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)
        job_result_id = argd["result_id"]
        output_format = argd["output_format"]

        title = _("Export Job Result")
        try:
            body = perform_request_display_job_result(
                job_result_id=job_result_id,
                output_format=output_format,
                user_id=user_id,
                language=language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title=title,
                    metaheaderadd=get_css(),
                    body=body,
                    req=req,
                    navmenuid="fieldexporter",
                    titleprologue=get_navigation_menu(language),
                    navtrail=self._NAVTRAIL_EXPORT,
                    language=language)
Exemple #3
0
    def job_queries(self, req, form):
        """Allows edition and manipulations of the queries of a job"""

        argd = wash_urlargd(
            form, {
                "new_button": (str, ""),
                "run_button": (str, ""),
                "delete_button": (str, ""),
                "selected_queries": (list, ""),
                "job_id": (int, -1)
            })
        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)
        job_id = argd["job_id"]

        try:
            # if the form is submitted through some of the buttons
            # we should perform the appropriate action
            if argd["new_button"]:
                new_query_url = "%s?job_id=%s" % (self._EDIT_QUERY_URL, job_id)
                self._redirect_to_page(req, new_query_url, language)
            if argd["delete_button"]:
                query_ids = argd["selected_queries"]
                perform_request_delete_queries(query_ids=query_ids,
                                               user_id=user_id,
                                               language=language)
            if argd["run_button"]:
                title = _("Query Results")
                query_ids = argd["selected_queries"]
                body = perform_request_run_queries(query_ids=query_ids,
                                                   user_id=user_id,
                                                   job_id=job_id,
                                                   language=language)
            else:
                title = _("Export Job Queries")
                body = perform_request_job_queries(job_id=job_id,
                                                   user_id=user_id,
                                                   language=language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title=title,
                    metaheaderadd=get_css(),
                    body=body,
                    req=req,
                    navmenuid="fieldexporter",
                    titleprologue=get_navigation_menu(language),
                    navtrail=self._NAVTRAIL_EXPORT,
                    language=language)
    def job_queries(self, req, form):
        """Allows edition and manipulations of the queries of a job"""

        argd = wash_urlargd(form, {
                                   "new_button": (str, ""),
                                   "run_button": (str, ""),
                                   "delete_button": (str, ""),
                                   "selected_queries": (list, ""),
                                   "job_id": (int, -1)
                                   })
        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)
        job_id = argd["job_id"]

        try:
            # if the form is submitted through some of the buttons
            # we should perform the appropriate action
            if argd["new_button"]:
                new_query_url = "%s?job_id=%s" % (self._EDIT_QUERY_URL, job_id)
                self._redirect_to_page(req, new_query_url, language)
            if argd["delete_button"]:
                query_ids = argd["selected_queries"]
                perform_request_delete_queries(query_ids = query_ids,
                                               user_id = user_id,
                                               language = language)
            if argd["run_button"]:
                title = _("Query Results")
                query_ids = argd["selected_queries"]
                body = perform_request_run_queries(query_ids = query_ids,
                                                   user_id = user_id,
                                                   job_id = job_id,
                                                   language = language)
            else:
                title = _("Export Job Queries")
                body = perform_request_job_queries(job_id = job_id,
                                                   user_id = user_id,
                                                   language = language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title = title,
                    metaheaderadd=get_css(),
                    body = body,
                    req = req,
                    navmenuid = "fieldexporter",
                    titleprologue = get_navigation_menu(language),
                    navtrail = self._NAVTRAIL_EXPORT,
                    language = language)
    def jobs(self, req, form):
        """Displays all the jobs of a given user
        and allows creation, deletion and execution of jobs"""

        argd = wash_urlargd(form, {
                                   "new_button": (str, ""),
                                   "run_button": (str, ""),
                                   "delete_button": (str, ""),
                                   "selected_jobs": (list, "")
                                   })

        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)

        try:
            # if the form is submitted through some of the buttons
            # we should perform the appropriate action
            if argd["new_button"]:
                self._redirect_to_page(req, self._EDIT_JOB_URL, language)
            elif argd["delete_button"]:
                job_ids = argd["selected_jobs"]
                perform_request_delete_jobs(job_ids = job_ids,
                                            user_id = user_id,
                                            language = language)
            elif argd["run_button"]:
                job_ids = argd["selected_jobs"]
                perform_request_run_jobs(job_ids = job_ids,
                                         user_id = user_id,
                                         language = language)
                self._redirect_to_page(req, self._JOB_HISTORY_URL, language)

            user_id = self._get_user_id(req)
            body = perform_request_jobs(user_id = user_id,
                                        language = language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title = _("Export Job Overview"),
                    metaheaderadd = get_css(),
                    body = body,
                    req = req,
                    navmenuid = "fieldexporter",
                    titleprologue = get_navigation_menu(language),
                    navtrail = self._NAVTRAIL_EXPORT,
                    language = language)
Exemple #6
0
    def jobs(self, req, form):
        """Displays all the jobs of a given user
        and allows creation, deletion and execution of jobs"""

        argd = wash_urlargd(
            form, {
                "new_button": (str, ""),
                "run_button": (str, ""),
                "delete_button": (str, ""),
                "selected_jobs": (list, "")
            })

        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)

        try:
            # if the form is submitted through some of the buttons
            # we should perform the appropriate action
            if argd["new_button"]:
                self._redirect_to_page(req, self._EDIT_JOB_URL, language)
            elif argd["delete_button"]:
                job_ids = argd["selected_jobs"]
                perform_request_delete_jobs(job_ids=job_ids,
                                            user_id=user_id,
                                            language=language)
            elif argd["run_button"]:
                job_ids = argd["selected_jobs"]
                perform_request_run_jobs(job_ids=job_ids,
                                         user_id=user_id,
                                         language=language)
                self._redirect_to_page(req, self._JOB_HISTORY_URL, language)

            user_id = self._get_user_id(req)
            body = perform_request_jobs(user_id=user_id, language=language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title=_("Export Job Overview"),
                    metaheaderadd=get_css(),
                    body=body,
                    req=req,
                    navmenuid="fieldexporter",
                    titleprologue=get_navigation_menu(language),
                    navtrail=self._NAVTRAIL_EXPORT,
                    language=language)
    def history(self, req, form):
        """Displays history of the jobs"""
        argd = wash_urlargd(form, {})

        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        title = _("Export Job History")
        user_id = self._get_user_id(req)
        body = perform_request_job_history(user_id, language)

        return page(title = title,
                    metaheaderadd = get_css(),
                    body = body,
                    req = req,
                    navmenuid = "fieldexporter",
                    titleprologue = get_navigation_menu(language),
                    navtrail = self._NAVTRAIL_EXPORT,
                    language = language)
Exemple #8
0
    def history(self, req, form):
        """Displays history of the jobs"""
        argd = wash_urlargd(form, {})

        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        title = _("Export Job History")
        user_id = self._get_user_id(req)
        body = perform_request_job_history(user_id, language)

        return page(title=title,
                    metaheaderadd=get_css(),
                    body=body,
                    req=req,
                    navmenuid="fieldexporter",
                    titleprologue=get_navigation_menu(language),
                    navtrail=self._NAVTRAIL_EXPORT,
                    language=language)
    def edit_query(self, req, form):
        """Edits an existing query or creates a new one"""

        # Create an empty job and use its default values
        # to init missing parameters
        query = Query()
        name = query.get_name()
        output_fields = ", ".join(query.get_output_fields())
        search_criteria = query.get_search_criteria()
        comment = query.get_comment()
        query_id = query.get_id()

        argd = wash_urlargd(form,
                            {"name": (str, name),
                            "search_criteria": (str, search_criteria),
                            "output_fields": (str, output_fields),
                            "comment": (str, comment),
                            "id": (int, query_id),
                            "job_id": (int, Job.ID_MISSING),
                            "save_button": (str, ""),
                            "cancel_button": (str, "")
                            })
        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)
        query_id = argd["id"]
        job_id = argd["job_id"]

        current_job_queries_url = "%s?job_id=%s" %(self._JOB_QUERIES_URL, job_id)

        try:
            if argd["cancel_button"]:
                self._redirect_to_page(req, current_job_queries_url, language)
            elif argd["save_button"]:
                name = argd["name"]
                search_criteria = argd["search_criteria"]
                comment = argd["comment"]

                # split the text entered by user to different fields
                outoutput_fields_text = argd["output_fields"]
                re_split_pattern = re.compile(r',\s*')
                output_fields = re_split_pattern.split(outoutput_fields_text)

                query = Query(query_id,
                              name,
                              search_criteria,
                              comment,
                              output_fields)
                perform_request_save_query(query = query,
                                           job_id = job_id,
                                           user_id = user_id,
                                           language = language)
                self._redirect_to_page(req, current_job_queries_url, language)
            elif Query.ID_MISSING == query_id:
                title = _("New Query")
                body = perform_request_new_query(job_id = job_id,
                                                 user_id = user_id,
                                                 language = language)
            else:
                title = _("Edit Query")
                body = perform_request_edit_query(query_id = query_id,
                                                  job_id = job_id,
                                                  user_id = user_id,
                                                  language = language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title = title,
                    metaheaderadd=get_css(),
                    body = body,
                    req = req,
                    navmenuid   = "fieldexporter",
                    titleprologue = get_navigation_menu(language),
                    navtrail = self._NAVTRAIL_EXPORT,
                    language = language)
    def edit_job(self, req, form):
        """Edits an existing job or creates a new one"""

        # Create an empty job and use its default values
        # to init missing parameters
        job = Job()

        argd = wash_urlargd(form,
                            {"job_name": (str, job.get_name()),
                            "output_directory": (str, job.get_output_directory()),
                            "job_frequency": (int, job.get_frequency()),
                            "output_format": (int, job.get_output_format()),
                            "last_run": (str, convert_datestruct_to_datetext(job.get_last_run())),
                            "id": (int, job.get_id()),
                            "save_button": (str, ""),
                            "cancel_button": (str, ""),
                            "edit_queries_button": (str, "")
                            })
        language = argd["ln"]
        # load the right message language
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)
        job_id = argd["id"]

        job = Job(job_id = job_id,
                  name = argd["job_name"],
                  frequency = argd["job_frequency"],
                  output_format = argd["output_format"],
                  last_run = convert_datetext_to_datestruct(argd["last_run"]),
                  output_directory = argd["output_directory"])
        try:
            if argd["cancel_button"]:
                self._redirect_to_page(req, self._JOBS_URL, language)
            elif argd["save_button"]:
                perform_request_save_job(job = job,
                                         user_id = user_id,
                                         language = language)
                self._redirect_to_page(req, self._JOBS_URL, language)
            elif argd["edit_queries_button"]:
                result_job_id = perform_request_save_job(job = job,
                                         user_id = user_id,
                                         language = language)
                edit_queries_url = "%s?job_id=%s" % (self._JOB_QUERIES_URL, result_job_id)
                self._redirect_to_page(req, edit_queries_url, language)
            elif Job.ID_MISSING == job_id:
                title = _("New Export Job")
                body = perform_request_new_job(language = language)
            else:
                title = _("Edit Export Job")
                body = perform_request_edit_job(job_id = job_id,
                                                user_id = user_id,
                                                language = language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title = title,
                    metaheaderadd=get_css(),
                    body = body,
                    req = req,
                    navmenuid = "fieldexporter",
                    titleprologue = get_navigation_menu(language),
                    navtrail = self._NAVTRAIL_EXPORT,
                    language = language)
Exemple #11
0
    def edit_query(self, req, form):
        """Edits an existing query or creates a new one"""

        # Create an empty job and use its default values
        # to init missing parameters
        query = Query()
        name = query.get_name()
        output_fields = ", ".join(query.get_output_fields())
        search_criteria = query.get_search_criteria()
        comment = query.get_comment()
        query_id = query.get_id()

        argd = wash_urlargd(
            form, {
                "name": (str, name),
                "search_criteria": (str, search_criteria),
                "output_fields": (str, output_fields),
                "comment": (str, comment),
                "id": (int, query_id),
                "job_id": (int, Job.ID_MISSING),
                "save_button": (str, ""),
                "cancel_button": (str, "")
            })
        # load the right message language
        language = argd["ln"]
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)
        query_id = argd["id"]
        job_id = argd["job_id"]

        current_job_queries_url = "%s?job_id=%s" % (self._JOB_QUERIES_URL,
                                                    job_id)

        try:
            if argd["cancel_button"]:
                self._redirect_to_page(req, current_job_queries_url, language)
            elif argd["save_button"]:
                name = argd["name"]
                search_criteria = argd["search_criteria"]
                comment = argd["comment"]

                # split the text entered by user to different fields
                outoutput_fields_text = argd["output_fields"]
                re_split_pattern = re.compile(r',\s*')
                output_fields = re_split_pattern.split(outoutput_fields_text)

                query = Query(query_id, name, search_criteria, comment,
                              output_fields)
                perform_request_save_query(query=query,
                                           job_id=job_id,
                                           user_id=user_id,
                                           language=language)
                self._redirect_to_page(req, current_job_queries_url, language)
            elif Query.ID_MISSING == query_id:
                title = _("New Query")
                body = perform_request_new_query(job_id=job_id,
                                                 user_id=user_id,
                                                 language=language)
            else:
                title = _("Edit Query")
                body = perform_request_edit_query(query_id=query_id,
                                                  job_id=job_id,
                                                  user_id=user_id,
                                                  language=language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title=title,
                    metaheaderadd=get_css(),
                    body=body,
                    req=req,
                    navmenuid="fieldexporter",
                    titleprologue=get_navigation_menu(language),
                    navtrail=self._NAVTRAIL_EXPORT,
                    language=language)
Exemple #12
0
    def edit_job(self, req, form):
        """Edits an existing job or creates a new one"""

        # Create an empty job and use its default values
        # to init missing parameters
        job = Job()

        argd = wash_urlargd(
            form, {
                "job_name": (str, job.get_name()),
                "output_directory": (str, job.get_output_directory()),
                "job_frequency": (int, job.get_frequency()),
                "output_format": (int, job.get_output_format()),
                "last_run":
                (str, convert_datestruct_to_datetext(job.get_last_run())),
                "id": (int, job.get_id()),
                "save_button": (str, ""),
                "cancel_button": (str, ""),
                "edit_queries_button": (str, "")
            })
        language = argd["ln"]
        # load the right message language
        _ = gettext_set_language(language)

        self._check_user_credentials(req, language)

        user_id = self._get_user_id(req)
        job_id = argd["id"]

        job = Job(job_id=job_id,
                  name=argd["job_name"],
                  frequency=argd["job_frequency"],
                  output_format=argd["output_format"],
                  last_run=convert_datetext_to_datestruct(argd["last_run"]),
                  output_directory=argd["output_directory"])
        try:
            if argd["cancel_button"]:
                self._redirect_to_page(req, self._JOBS_URL, language)
            elif argd["save_button"]:
                perform_request_save_job(job=job,
                                         user_id=user_id,
                                         language=language)
                self._redirect_to_page(req, self._JOBS_URL, language)
            elif argd["edit_queries_button"]:
                result_job_id = perform_request_save_job(job=job,
                                                         user_id=user_id,
                                                         language=language)
                edit_queries_url = "%s?job_id=%s" % (self._JOB_QUERIES_URL,
                                                     result_job_id)
                self._redirect_to_page(req, edit_queries_url, language)
            elif Job.ID_MISSING == job_id:
                title = _("New Export Job")
                body = perform_request_new_job(language=language)
            else:
                title = _("Edit Export Job")
                body = perform_request_edit_job(job_id=job_id,
                                                user_id=user_id,
                                                language=language)
        except AccessDeniedError:
            self._redirect_to_not_authorised_page(req, language)

        return page(title=title,
                    metaheaderadd=get_css(),
                    body=body,
                    req=req,
                    navmenuid="fieldexporter",
                    titleprologue=get_navigation_menu(language),
                    navtrail=self._NAVTRAIL_EXPORT,
                    language=language)