Skip to content

Commit

Permalink
Allow upload of judgments
Browse files Browse the repository at this point in the history
+ Add new endpoint to bmi_fcgi to check if a document id exists
+ allow session deletion
+ clean judgment modal source fields
+ Dynamically show some form fields
  • Loading branch information
ammsa committed May 31, 2020
1 parent 00f2328 commit be72f59
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
4 changes: 0 additions & 4 deletions HiCALWeb/hicalweb/archive/templates/archive/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ <h5 class="gray-text align-left">Highlight content</h5>

{% block extra_scripts %}
<script>
// since crispy forms doesn't make it easy to position submit button in forms...
$('#import_csv_button').click(function() {
$("#import_csv_form").submit();
});

var loaded_docs = {}; // dict of loaded documents to prevent reloading doc content.

Expand Down
1 change: 1 addition & 0 deletions HiCALWeb/hicalweb/judgment/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, *args, **kwargs):
self.helper = FormHelper(self)
self.helper.use_custom_control = True
self.helper.help_text_inline = True
self.helper.form_tag = False

self.helper.layout = Layout(
'csv_file',
Expand Down
20 changes: 14 additions & 6 deletions HiCALWeb/hicalweb/progress/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from crispy_forms.bootstrap import StrictButton
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout, Column, Row
from crispy_forms.layout import Submit, Layout, Column, Row, Field, Div
from django import forms
from django.db.models import Q
from hicalweb.progress.models import Task
Expand All @@ -13,14 +13,14 @@ class TaskForm(forms.ModelForm):
"""
submit_name = 'submit-task-form'
prefix = "predefined"

class Meta:
model = Task
exclude = ["username", "setting", "timespent", "last_activity"]
help_texts = {
'max_number_of_judgments': '(Optional) Set max number of judgments.',
'strategy': 'CAL strategy of retrieval.',
'show_full_document_content': 'Only for paragraph strategies.'
}

max_number_of_judgments = forms.IntegerField(required=False,
Expand All @@ -40,7 +40,11 @@ def __init__(self, *args, **kwargs):
Column('strategy', css_class='form-group col-md-6 mb-0'),
css_class='form-row'
),
'show_full_document_content',
Div(
Field('show_full_document_content'),
css_class='d-none',
css_id="predefined-show_full_document_content"
),
StrictButton(u'Select topic and start judging',
name=self.submit_name,
type="submit",
Expand All @@ -60,6 +64,7 @@ class TopicForm(forms.ModelForm):
"""
submit_name = 'submit-topic-form'
prefix = "topic"

class Meta:
model = Topic
Expand All @@ -71,8 +76,7 @@ class Meta:
strategy = forms.ChoiceField(choices=Task.STRATEGY_CHOICES,
required=True,
help_text=TaskForm.Meta.help_texts.get('strategy'))
show_full_document_content = forms.BooleanField(required=False,
help_text=TaskForm.Meta.help_texts.get('show_full_document_content'))
show_full_document_content = forms.BooleanField(required=False)

def __init__(self, *args, **kwargs):
super(TopicForm, self).__init__(*args, **kwargs)
Expand All @@ -90,7 +94,11 @@ def __init__(self, *args, **kwargs):
Column('strategy', css_class='form-group col-md-6 mb-0'),
css_class='form-row'
),
'show_full_document_content',
Div(
Field('show_full_document_content'),
css_class='d-none',
css_id="topic-show_full_document_content"
),
StrictButton(u'Create topic and start judging',
name=self.submit_name,
type="submit",
Expand Down
23 changes: 23 additions & 0 deletions HiCALWeb/hicalweb/progress/templates/progress/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,26 @@ <h2 class="text-secondary">Create new topic</h2>

</div>
{% endblock %}

{% block extra_scripts %}
<script>
// dynamically show "show_full_document_content" field based on strategy field value
$('#id_topic-strategy').on('change', function() {
let newval = this.value;
if (newval.includes("para")){
$("#topic-show_full_document_content").removeClass("d-none");
}else{
$("#topic-show_full_document_content").addClass("d-none");
}
});
$('#id_predefined-strategy').on('change', function() {
let newval = this.value;
if (newval.includes("para")){
$("#predefined-show_full_document_content").removeClass("d-none");
}else{
$("#predefined-show_full_document_content").addClass("d-none");
}
});
</script>

{% endblock %}

0 comments on commit be72f59

Please sign in to comment.