Beispiel #1
0
 def post(self):
     flag = request.args.get('flag')
     title = self.TITLE_MAP.get(flag, self.DOC_TITLE)
     template_name = 'printouts_aewa/_provisional_list_pdf.html'
     _add_to_printout_queue(_process_provisional_list, self.JOB_NAME, title,
                            flag, template_name)
     return redirect(url_for('.printouts_provisional_list', flag=flag))
Beispiel #2
0
 def post(self):
     category_ids = request.args.getlist('categories')
     template_name = 'printouts_aewa/_verification_table_pdf.html'
     _add_to_printout_queue(_process_verification, self.JOB_NAME,
                            self.DOC_TITLE, category_ids, template_name)
     return redirect(
         url_for('.printouts_verification', categories=category_ids))
 def post(self):
     flag = request.args.get('flag')
     category_ids = request.args.getlist('categories')
     _add_to_printout_queue(_process_media, self.JOB_NAME, self.DOC_TITLE,
                            flag, category_ids)
     return redirect(
         url_for('.printouts_media', flag=flag, categories=category_ids))
 def post(self):
     flag = request.args.get('flag')
     category_tags = request.args.getlist('category_tags')
     _add_to_printout_queue(_process_credentials, self.JOB_NAME,
                            self.DOC_TITLE, flag, category_tags)
     return redirect(
         url_for('.printouts_credentials',
                 flag=flag,
                 category_tags=category_tags))
Beispiel #5
0
 def post(self):
     category_ids = request.args.getlist('categories')
     size = request.form.get('printout_size', 'default')
     flag = request.args.get('flag')
     _add_to_printout_queue(_process_badges, self.JOB_NAME, flag, size,
                            category_ids)
     return redirect(
         url_for('.printouts_participant_badges',
                 categories=category_ids,
                 flag=flag))
 def post(self):
     flag = request.args.get('flag')
     title = self.TITLE_MAP.get(flag, self.DOC_TITLE)
     try:
         categories = map(int, request.args.getlist("category_filter"))
     except (KeyError, ValueError, TypeError):
         categories = []
     selected_field_ids = self._get_selected_field_ids()
     _add_to_printout_queue(_process_provisional_list, self.JOB_NAME, title,
                            flag, None, selected_field_ids, categories)
     return redirect(url_for('.printouts_provisional_list', flag=flag))
 def post(self):
     flag = request.args.get('flag')
     category_tags = request.args.getlist('category_tags')
     categories = request.args.getlist('categories')
     args = (self.DOC_TITLE, flag, category_tags, categories)
     _add_to_printout_queue(_process_observers, self.JOB_NAME, *args)
     return redirect(
         url_for('.printouts_observers',
                 flag=flag,
                 category_tags=category_tags,
                 categories=categories))
Beispiel #8
0
 def post(self):
     flag = request.args.get('flag')
     category_tags = request.args.getlist('category_tags')
     args = (
         flag,
         category_tags,
     )
     _add_to_printout_queue(_process_admission, self.JOB_NAME, *args)
     return redirect(
         url_for('.printouts_admission',
                 flag=flag,
                 category_tags=category_tags))
Beispiel #9
0
 def post(self):
     _add_to_printout_queue(_process_participants_excel, self.JOB_NAME,
                            Participant.MEDIA)
     return redirect(url_for('meetings.media_participants'))
Beispiel #10
0
 def post(self):
     flag = request.args.get('flag')
     _add_to_printout_queue(_process_distribution, self.JOB_NAME,
                            self.printout_type, self.DOC_TITLE, flag)
     return redirect(url_for(self.view_name, flag=flag))
Beispiel #11
0
 def post(self):
     event_ids = request.args.getlist('events')
     _add_to_printout_queue(_process_event_list, self.JOB_NAME,
                            self.DOC_TITLE, event_ids)
     return redirect(
         url_for('.printouts_participant_events', events=event_ids))
Beispiel #12
0
 def post(self):
     flag = request.args.get('flag')
     _add_to_printout_queue(_process_delegation_list, self.JOB_NAME,
                            self.DOC_TITLE, flag)
     return redirect(url_for('.printouts_delegation_list', flag=flag))
Beispiel #13
0
 def post(self):
     flag = request.args.get('flag')
     title = self.TITLE_MAP.get(flag, self.DOC_TITLE)
     _add_to_printout_queue(_process_provisional_list, self.JOB_NAME, title,
                            flag)
     return redirect(url_for('.printouts_provisional_list', flag=flag))
 def post(self):
     _add_to_printout_queue(_process_export_participants_excel,
                            self.JOB_NAME, Participant.PARTICIPANT)
     return redirect(url_for('meetings.participants'))
    def post(self):
        if request.files.get("import_file"):
            try:
                xlsx = openpyxl.load_workbook(request.files["import_file"],
                                              read_only=True)
            except (zipfile.BadZipfile, InvalidFileException) as e:
                flash("Invalid XLS file: %s" % e, 'danger')
                context = {
                    "participant_type": self.participant_type,
                }
                return render_template('meetings/participant/import/list.html',
                                       **context)

            request.files["import_file"].seek(0)
            file_name = str(uuid.uuid4()) + '.xlsx'
            # Save the file so we only upload it once.
            request.files["import_file"].save(
                app.config['UPLOADED_PRINTOUTS_DEST'] / file_name)

        else:
            file_name = request.form["file_name"]
            try:
                xlsx = openpyxl.load_workbook(
                    app.config['UPLOADED_PRINTOUTS_DEST'] / file_name,
                    read_only=True)
            except (zipfile.BadZipfile, InvalidFileException) as e:
                flash("Invalid XLS file: %s" % e, 'danger')
                context = {
                    "participant_type": self.participant_type,
                }
                return render_template('meetings/participant/import/list.html',
                                       **context)

        custom_fields = (g.meeting.custom_fields.filter_by(
            custom_field_type=self.participant_type).order_by(
                CustomField.sort))
        custom_fields = [
            field for field in custom_fields
            if field.field_type.code != CustomField.EVENT
        ]

        has_errors = False

        try:
            rows = list(read_sheet(xlsx, custom_fields))
            assert rows, "file has no data"
        except (AssertionError, ValueError) as e:
            flash("Invalid XLS file: %s" % e, 'danger')
            context = {
                "participant_type": self.participant_type,
            }
            return render_template('meetings/participant/import/list.html',
                                   **context)

        forms = []
        for form in read_participants_excel(custom_fields, rows,
                                            self.form_class):
            has_errors = not form.validate() or has_errors
            forms.append(form)

        all_fields = list(
            custom_form_factory(self.form_class)().exclude([
                CustomField.EVENT,
            ]))
        context = {
            "forms": forms,
            "has_errors": has_errors,
            "all_fields": all_fields,
            "file_name": file_name,
            "participant_type": self.participant_type,
        }

        if has_errors:
            flash(
                'XLS file has errors, please review and correct them and try again. '
                'Hover over cells to find more about the errors.', 'danger')
        elif request.form["action"] == "import":
            _add_to_printout_queue(_process_import_participants_excel,
                                   self.JOB_NAME, rows, self.participant_type,
                                   self.form_class)
            context["import_started"] = True
        else:
            flash(
                'XLS file is valid, please review and hit "Start import" after.',
                'success',
            )

        return render_template('meetings/participant/import/list.html',
                               **context)
 def post(self):
     category_ids = request.args.getlist('categories')
     _add_to_printout_queue(_process_verification, self.JOB_NAME,
                            self.DOC_TITLE, category_ids)
     return redirect(
         url_for('.printouts_verification', categories=category_ids))