Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 5.2.20 on 2026-12-03 18:54

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("funds", "0141_applicationsubmission_form_data_gin"),
]

operations = [
migrations.AddField(
model_name="applicationbase",
name="allow_copying_to_clipboard",
field=models.BooleanField(
default=True,
help_text='Should the lab\'s application form be copiable to clipboard via the "Copy to clipboard" button.',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should say "fund" and not "lab" I think.

verbose_name="Make questions copyable to clipboard",
),
),
migrations.AddField(
model_name="labbase",
name="allow_copying_to_clipboard",
field=models.BooleanField(
default=True,
help_text='Should the lab\'s application form be copiable to clipboard via the "Copy to clipboard" button.',
verbose_name="Make questions copyable to clipboard",
),
),
]
18 changes: 18 additions & 0 deletions hypha/apply/funds/models/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ class ApplicationBase(EmailForm, WorkflowStreamForm, AsJsonMixin): # type: igno
help_text=_("Should the fund be listed on the front page."),
)

allow_copying_to_clipboard = models.BooleanField(
_("Make questions copyable to clipboard"),
default=True,
help_text=_(
'Should the lab\'s application form be copyable to clipboard via the "Copy to clipboard" button.'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should say "fund" and not "lab" I think.

),
)

show_deadline = models.BooleanField(
_("show deadline"),
default=True,
Expand Down Expand Up @@ -219,6 +227,7 @@ def serve(self, request):
FieldPanel("slack_channel"),
FieldPanel("activity_digest_recipient_emails"),
FieldPanel("list_on_front_page"),
FieldPanel("allow_copying_to_clipboard"),
FieldPanel("show_deadline"),
]

Expand Down Expand Up @@ -688,6 +697,14 @@ class LabBase(EmailForm, WorkflowStreamForm, SubmittableStreamForm, AsJsonMixin)
help_text=_("Should the lab be listed on the front page."),
)

allow_copying_to_clipboard = models.BooleanField(
_("Make questions copyable to clipboard"),
default=True,
help_text=_(
'Should the lab\'s application form be copyable to clipboard via the "Copy to clipboard" button.'
),
)

parent_page_types = ["apply_home.ApplyHomePage"]
subpage_types = [] # type: ignore

Expand All @@ -702,6 +719,7 @@ class LabBase(EmailForm, WorkflowStreamForm, SubmittableStreamForm, AsJsonMixin)
FieldPanel("submission_id_prefix"),
FieldPanel("activity_digest_recipient_emails"),
FieldPanel("list_on_front_page"),
FieldPanel("allow_copying_to_clipboard"),
]

edit_handler = TabbedInterface(
Expand Down
14 changes: 9 additions & 5 deletions hypha/apply/funds/templates/funds/application_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ <h4>
</a>
{% endif %}
<form class="form application-form" action="/test500/" method="post" enctype="multipart/form-data"
data-copy-btn-label="{% trans 'Copy questions to clipboard' %}"
data-copy-btn-title="{% trans 'Copies all the questions and user input to the clipboard in plain text.' %}"
data-copy-word-limit="{% trans 'Limit this field to %s words.' %}"
data-copy-selected="{% trans '(selected)' %}"
{% if page.get_parent.specific.allow_copying_to_clipboard %}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To cache add this to def fund():

@cached_property
def allow_copying_to_clipboard(self):
  return self.fund.specific.allow_copying_to_clipboard

And then use "{% if page.allow_copying_to_clipboard %}".

data-copy-btn-label="{% trans 'Copy questions to clipboard' %}"
data-copy-btn-title="{% trans 'Copies all the questions and user input to the clipboard in plain text.' %}"
data-copy-word-limit="{% trans 'Limit this field to %s words.' %}"
data-copy-selected="{% trans '(selected)' %}"
{% endif %}
>
{% csrf_token %}
{% for field in form %}
Expand Down Expand Up @@ -145,7 +147,9 @@ <h4>

{% block extra_js %}
<script src="{% static 'js/application-form.js' %}"></script>
<script src="{% static 'js/submission-form-copy.js' %}"></script>
{% if page.get_parent.specific.allow_copying_to_clipboard %}
<script src="{% static 'js/submission-form-copy.js' %}"></script>
{% endif %}
{% if not show_all_group_fields %}
<script src="{% static 'js/form-group-toggle.js' %}"></script>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

<div class="grow">
<form class="form application-form" action="" method="post" enctype="multipart/form-data"
data-copy-btn-label="{% trans 'Copy questions to clipboard' %}"
data-copy-btn-title="{% trans 'Copies all the questions and user input to the clipboard in plain text.' %}"
data-copy-word-limit="{% trans 'Limit this field to %s words.' %}"
data-copy-selected="{% trans '(selected)' %}"
{% if object.page.specific.allow_copying_to_clipboard %}
data-copy-btn-label="{% trans 'Copy questions to clipboard' %}"
data-copy-btn-title="{% trans 'Copies all the questions and user input to the clipboard in plain text.' %}"
data-copy-word-limit="{% trans 'Limit this field to %s words.' %}"
data-copy-selected="{% trans '(selected)' %}"
{% endif %}
>
{% csrf_token %}
{% for field in form %}
Expand Down Expand Up @@ -69,7 +71,9 @@
{% block extra_js %}
<script src="{% static 'js/application-form.js' %}"></script>
<script src="{% static 'js/multi-input-fields-alpine.js' %}"></script>
<script src="{% static 'js/submission-form-copy.js' %}"></script>
{% if object.page.specific.allow_copying_to_clipboard %}
<script src="{% static 'js/submission-form-copy.js' %}"></script>
{% endif %}
{% if not show_all_group_fields %}
<script src="{% static 'js/form-group-toggle.js' %}"></script>
{% endif %}
Expand Down
Loading