Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy recent updates to production #345

Merged
merged 17 commits into from
Jul 11, 2024
Merged
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
16 changes: 16 additions & 0 deletions backend/django/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ class Meta:
description = forms.CharField(required=False)


class ProjectUpdateAdvancedForm(forms.ModelForm):
class Meta:
model = Project
fields = ["allow_coders_view_labels"]

def __init__(self, *args, **kwargs):
percentage_irr = kwargs.pop("percentage_irr")
super(ProjectUpdateAdvancedForm, self).__init__(*args, **kwargs)
if percentage_irr > 0:
self.fields["allow_coders_view_labels"].widget.attrs[
"disabled"
] = "disabled"


class LabelForm(forms.ModelForm):
class Meta:
model = Label
Expand Down Expand Up @@ -263,6 +277,8 @@ class Meta:
required=False,
)

allow_coders_view_labels = forms.BooleanField(initial=False, required=False)

def clean(self):
use_active_learning = self.cleaned_data.get("use_active_learning")
use_default_batch_size = self.cleaned_data.get("use_default_batch_size")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.9 on 2024-06-12 14:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0076_auto_20230710_1905"),
]

operations = [
migrations.AddField(
model_name="project",
name="allow_coders_view_labels",
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions backend/django/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Meta:
num_users_irr = models.IntegerField(default=2, validators=[MinValueValidator(2)])
codebook_file = models.TextField(default="")
batch_size = models.IntegerField(default=30)
allow_coders_view_labels = models.BooleanField(default=False)
umbrella_string = models.TextField(blank=True)
""" Advanced options """
# the current options are 'random', 'least confident', 'entropy', and 'margin sampling'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h5 class="panel-title">
<div class="panel-body">
<div id="choose_classifier_box">
<div id="use_model_div">
<p>Train and display results for a model: {{ wizard.form.use_model }}</p>
<p>{{ wizard.form.use_model }} Train and display results for a model</p>
<p>NOTE: This option must be checked to use Active Learning</p>
<br />
</div>
Expand Down Expand Up @@ -85,16 +85,24 @@ <h5 class="panel-title">
</div>
<div id="irr-panel" class="panel-collapse collapse hide">
<div class="panel-body">
<p>Under IRR, a certain percentage of the data is labeled by
multiple coders. The project admin can then examine the
consistency of the labels across different coders. The options
below allow you to set what percentage of the data is coded
multiple times, and how many coders must code data designated
for IRR before it is analyzed.
</p>
<div id = "choose_irr_or_not">
<p>Under IRR, a certain percentage of the data is labeled by
multiple coders. The project admin can then examine the
consistency of the labels across different coders. The options
below allow you to set what percentage of the data is coded
multiple times, and how many coders must code data designated
for IRR before it is analyzed.
</p>
{{ wizard.form.use_irr }} Use Inter-rater Reliability
</div>
<div id="choose_irr_or_not_disabled" style="display: none">
<input disabled type="checkbox" />
Use Inter-rater Reliability
<br />
<p> <i>
*This option is only enabled if project does not use IRR
</i></p>
</div>
<div id="IRR_options">
Percent of batch marked IRR (must be between 0 and 100):{{ wizard.form.percentage_irr }}%
<br />
Expand All @@ -118,6 +126,30 @@ <h5 class="panel-title">
</div>
</div>
</div>

</div>
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<a data-toggle="collapse" href="#coders-view-labels-panel" class="accordion-toggle collapsed">
Coder Label Viewing Permissions
</a>
</h5>
</div>
<div id="coders-view-labels-panel" class="panel-collapse collapse hide">
<div class="panel-body">
<div id="allow_coders_view_labels">
{{ wizard.form.allow_coders_view_labels }} Allow coders to view other users' labels in history table
</div>
<div id="allow_coders_view_labels_disabled" style="display: none">
<input disabled type="checkbox" />
Allow coders to view other users' labels in history table
<br />
<p><i>*This option is disabled when IRR is enabled</i></p>
</div>

</div>
</div>
</div>
</div>

Expand Down Expand Up @@ -145,10 +177,14 @@ <h5 class="panel-title">
*/
var methods_box = $('div#choose_method_box');
var irr_box = $('div#IRR_options');
var irr_or_not_box = $('div#choose_irr_or_not');
var irr_or_not_box_disabled = $('div#choose_irr_or_not_disabled');
var batch_field = $('#choose_batch_size');
var use_model = $('#use_model_div');
var class_choice = $('#classifier_radios');
var al_tab = $('#al_tab');
var allow_coders_box = $('#allow_coders_view_labels');
var allow_coders_box_disabled = $('#allow_coders_view_labels_disabled');

if ($('input#id_advanced-use_irr').prop('checked') == true) {
irr_box.show();
Expand Down Expand Up @@ -208,8 +244,22 @@ <h5 class="panel-title">
$('input#id_advanced-use_irr').change(function() {
if ($(this).prop('checked') == true) {
irr_box.show();
allow_coders_box.hide();
allow_coders_box_disabled.show();
} else {
irr_box.hide();
allow_coders_box.show()
allow_coders_box_disabled.hide();
}
});

$('input#id_advanced-allow_coders_view_labels').change(function() {
if ($(this).prop('checked') == true) {
irr_or_not_box.hide();
irr_or_not_box_disabled.show();
} else {
irr_or_not_box.show();
irr_or_not_box_disabled.hide();
}
});
</script>
Expand Down
43 changes: 43 additions & 0 deletions backend/django/core/templates/projects/update/advanced.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% extends "base.html" %}
{% block page_title %}Update Project Overview{% endblock %}
{% load static %}
{% load render_bundle from webpack_loader %}

{% block content %}
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="card">
<div class="cardface">
{{ form.media.css }}
<form action="." method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group">
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<a data-toggle="collapse" href="#coders-view-labels-panel" class="accordion-toggle collapsed">
Coder Label Viewing Permissions
</a>
</h5>
</div>
<div id="coders-view-labels-panel" class="panel-collapse collapse hide">
<div class="panel-body">
<div id="allow_coders_view_labels">
{{ form.allow_coders_view_labels }} Allow coders to view other users' labels in history table
</div>
<i>
*This option is only enabled if project does not use IRR
</i>
</div>
</div>
</div>
</div>


<button class="btn btn-primary" type="submit">Submit</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions backend/django/core/templates/projects/update_landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h1>Update Project</h1>
<li class="update-list"><a class="btn btn-primary" href="{% url 'projects:project_update_codebook' project.pk %}" role="button">{% if project.codebook_file == '' %}Upload Codebook{% else %}Change Codebook{% endif%}</a></li>
<li class="update-list"><a class="btn btn-primary" href="{% url 'projects:project_update_permissions' project.pk %}" role="button">Update Project Permissions</a></li>
<li class="update-list"><a class="btn btn-primary" href="{% url 'projects:project_update_labels' project.pk %}" role="button">Update Label Descriptions</a></li>
<li class="update-list"><a class="btn btn-primary" href="{% url 'projects:project_update_advanced' project.pk %}" role="button">Update Advanced Settings</a></li>
<li class="update-list"><a class="btn btn-primary" href="{% url 'projects:project_update_umbrella' project.pk %}" role="button">Add Project To Group</a></li>
</ul>
</div>
Expand Down
4 changes: 3 additions & 1 deletion backend/django/core/urls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
),
re_path(r"^unassign_data/(?P<data_pk>\d+)/$", api_annotate.unassign_data),
re_path(r"^skip_data/(?P<data_pk>\d+)/$", api_annotate.skip_data),
re_path(r"^verify_label/(?P<data_pk>\d+)/$", api_annotate.verify_label),
re_path(
r"^toggle_verify_label/(?P<data_pk>\d+)/$", api_annotate.toggle_verify_label
),
re_path(
r"^enter_coding_page/(?P<project_pk>\d+)/$", api_annotate.enter_coding_page
),
Expand Down
5 changes: 5 additions & 0 deletions backend/django/core/urls/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
frontend.ProjectUpdateOverview.as_view(),
name="project_update_overview",
),
re_path(
r"^projects/(?P<pk>\d+)/update/advanced/$",
frontend.ProjectUpdateAdvanced.as_view(),
name="project_update_advanced",
),
re_path(
r"^projects/(?P<pk>\d+)/update/data/$",
frontend.ProjectUpdateData.as_view(),
Expand Down
Loading