コード例 #1
0
ファイル: forms.py プロジェクト: ResetNetwork/apply-app
class BaseProposalDeterminationForm(forms.Form):
    titles = {
        1: 'A. Determination',
        2: 'B. General thoughts',
        3: 'C. Specific aspects',
        4: 'D. Rationale and appropriateness consideration',
        5: 'E. General recommendation',
    }

    # A. Determination

    outcome = forms.ChoiceField(
        choices=DETERMINATION_CHOICES,
        label=_('Determination'),
        help_text='Do you recommend requesting a proposal based on this concept note?'
    )
    outcome.group = 1

    message = RichTextField(
        label=_('Determination message'),
        help_text='This text will be e-mailed to the applicant. '
        'Ones when text is first added and then every time the text is changed.'
    )
    message.group = 1

    # B. General thoughts
    liked = RichTextField(
        label=_('Positive aspects'),
        help_text='Any general or specific aspects that got you really excited or that you like about this proposal.'
    )
    liked.group = 2

    concerns = RichTextField(
        label=_('Concerns'),
        help_text='Any general or specific aspects that concern you or leave you feeling uneasy about this proposal.'
    )
    concerns.group = 2

    red_flags = RichTextField(
        label=_('Items that must be addressed'),
        help_text='Anything you think should be flagged for our attention.'
    )
    red_flags.group = 2

    # C. Specific aspects
    overview = RichTextField(label=_('Project overview questions and comments'))
    overview.group = 3

    objectives = RichTextField(label=_('Objectives questions and comments'))
    objectives.group = 3

    strategy = RichTextField(label=_('Methods and strategy questions and comments'))
    strategy.group = 3

    technical = RichTextField(label=_('Technical feasibility questions and comments'))
    technical.group = 3

    alternative = RichTextField(label=_('Alternative analysis - "red teaming" questions and comments'))
    alternative.group = 3

    usability = RichTextField(label=_('Usability questions and comments'))
    usability.group = 3

    sustainability = RichTextField(label=_('Sustainability questions and comments'))
    sustainability.group = 3

    collaboration = RichTextField(label=_('Collaboration questions and comments'))
    collaboration.group = 3

    realism = RichTextField(label=_('Cost realism questions and comments'))
    realism.group = 3

    qualifications = RichTextField(label=_('Qualifications questions and comments'))
    qualifications.group = 3

    evaluation = RichTextField(label=_('Evaluation questions and comments'))
    evaluation.group = 3

    # D. Rationale and appropriateness consideration
    rationale = RichTextField(label=_('Rationale and appropriateness questions and comments'))
    rationale.group = 4
コード例 #2
0
class ReportEditForm(FileFormMixin, forms.ModelForm):
    public_content = RichTextField(help_text=_(
        'This section of the report will be shared with the broader community.'
    ))
    private_content = RichTextField(help_text=_(
        'This section of the report will be shared with staff only.'))
    file_list = forms.ModelMultipleChoiceField(
        widget=forms.CheckboxSelectMultiple(attrs={'class': 'delete'}),
        queryset=ReportPrivateFiles.objects.all(),
        required=False,
        label='Files')
    files = MultiFileField(required=False, label='')

    class Meta:
        model = Report
        fields = (
            'public_content',
            'private_content',
            'file_list',
            'files',
        )

    def __init__(self, *args, user=None, initial={}, **kwargs):
        self.report_files = initial.pop(
            'file_list',
            ReportPrivateFiles.objects.none(),
        )
        super().__init__(*args, initial=initial, **kwargs)
        self.fields['file_list'].queryset = self.report_files
        self.user = user

    def clean(self):
        cleaned_data = super().clean()
        public = cleaned_data['public_content']
        private = cleaned_data['private_content']
        if not private and not public:
            missing_content = _(
                'Must include either public or private content when submitting a report.'
            )
            self.add_error('public_content', missing_content)
            self.add_error('private_content', missing_content)
        return cleaned_data

    @transaction.atomic
    def save(self, commit=True):
        is_draft = 'save' in self.data

        version = ReportVersion.objects.create(
            report=self.instance,
            public_content=self.cleaned_data['public_content'],
            private_content=self.cleaned_data['private_content'],
            submitted=timezone.now(),
            draft=is_draft,
            author=self.user,
        )

        if is_draft:
            self.instance.draft = version
        else:
            # If this is the first submission of the report we track that as the
            # submitted date of the report
            if not self.instance.submitted:
                self.instance.submitted = version.submitted
            self.instance.current = version
            self.instance.draft = None

        instance = super().save(commit)

        removed_files = self.cleaned_data['file_list']
        ReportPrivateFiles.objects.bulk_create(
            ReportPrivateFiles(report=version, document=file.document)
            for file in self.report_files if file not in removed_files)

        added_files = self.cleaned_data['files']
        if added_files:
            ReportPrivateFiles.objects.bulk_create(
                ReportPrivateFiles(report=version, document=file)
                for file in added_files)

        return instance
コード例 #3
0
ファイル: forms.py プロジェクト: ResetNetwork/apply-app
class BaseConceptDeterminationForm(forms.Form):
    titles = {
        1: 'Feedback',
    }
    outcome = forms.ChoiceField(
        choices=DETERMINATION_CHOICES,
        label=_('Determination'),
        help_text='Do you recommend requesting a proposal based on this concept note?',
    )
    outcome.group = 1

    message = RichTextField(
        label=_('Determination message'),
        help_text='This text will be e-mailed to the applicant. '
        'Ones when text is first added and then every time the text is changed.'
    )
    message.group = 1

    principles = RichTextField(
        label=_('Goals and principles'),
        help_text='Does the project contribute and/or have relevance to OTF goals and principles?'
        'Are the goals and objectives of the project clear? Is it a technology research, development, or deployment '
        'project? Can project’s effort be explained to external audiences and non-technical people? What problem are '
        'they trying to solve and is the solution strategical or tactical? Is the project strategically or tactically '
        'important to OTF’s goals, principles and rationale and other OTF efforts? Is it clear how? What tools, if any, '
        'currently exist to solve this problem? How is this project different? Does the effort have any overlap with '
        'existing OTF and/or USG supported projects? Is the overlap complementary or duplicative? If complementary, '
        'can it be explained clearly? I.e. geographic focus, technology, organization profile, etc. What are the '
        'liabilities and risks of taking on this project? I.e. political personalities, financial concerns, technical '
        'controversial, etc. Is the organization or its members known within any relevant communities? If yes, what is '
        'their reputation and why? What is the entity’s motivation and principles? What are the entity member(s) '
        'motivations and principles? Where is the organization physically and legally based? If the organization is '
        'distributed, where is the main point of contact? Does the organization have any conflicts of interest with '
        'RFA, OTF, the Advisory Council, or other RFA-OTF projects? Is the project team an organization, community '
        'or an individual?'
    )
    principles.group = 1

    technical = RichTextField(
        label=_('Technical merit'),
        help_text='Does the project clearly articulate the technical problem, solution, and approach? '
        'Is the problem clearly justifiable? Does the project clearly articulate the technological objectives? '
        'Is it an open or closed development project? I.e. Open source like Android or open source like Firefox OS '
        'or closed like iOS. Does a similar technical solution already exist? If so, what are the differentiating '
        'factors? Is the effort to sustain an existing technical approach? If so, are these considered successful? '
        'Is the effort a new technical approach or improvement to an existing solution? If so, how? Is the effort '
        'a completely new technical approach fostering new solutions in the field? Does the project’s technical '
        'approach solve the problem? What are the limitations of the project’s technical approach and solution? '
        'What are the unintended or illicit uses and consequences of this technology? Has the project identified '
        'and/or developed any safeguards for these consequences?'
    )
    technical.group = 1

    sustainable = RichTextField(
        label=_('Reasonable, realistic and sustainable'),
        help_text='Is the requested amount reasonable, realistic, and justified? If OTF doesn’t support the project, '
        'is it likely to be realized? Does the project provide a detailed and realistic description of effort and '
        'schedule? I.e. is the project capable of creating a work plan including objectives, activities, and '
        'deliverable(s)? Does the project have a clear support model? Is there a known sustainability plan for the '
        'future? What in-kind support or other revenue streams is the project receiving? I.e. volunteer developers, '
        'service or product sales. Is the project receiving any financial support from the USG? Is this information '
        'disclosed? Is the project receiving any other financial support? Is this information disclosed? Are existing '
        'supporters approachable? Are they likely aware and/or comfortable with the Intellectual property language '
        'within USG contracts?'
    )
    sustainable.group = 1

    comments = RichTextField(
        label=_('Other comments'),
        help_text=''
    )
    comments.group = 1