Skip to content

Commit

Permalink
Merge pull request #174 from edwardchalstrey1/Qing-merge-25june
Browse files Browse the repository at this point in the history
Merge latest updates from upstream Qing branch 25 June 2024
  • Loading branch information
edwardchalstrey1 authored Jun 25, 2024
2 parents 6b593c3 + 9f1fcaa commit 509f316
Show file tree
Hide file tree
Showing 29 changed files with 4,794 additions and 463 deletions.
2 changes: 1 addition & 1 deletion seshat/apps/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CustomUserAdmin(admin.ModelAdmin):
inlines = (ProfileInline, )

list_display = ('username', 'email', 'first_name',
'last_name', 'is_staff', 'get_location','get_email_confirmed')
'last_name', 'is_staff', 'date_joined', 'last_login','get_email_confirmed')
list_select_related = ('profile', )

def get_location(self, instance):
Expand Down
68 changes: 63 additions & 5 deletions seshat/apps/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,20 @@ class Meta:
class ReferenceWithPageForm(forms.Form):
ref = forms.ModelChoiceField(
queryset=Reference.objects.all(),
widget=forms.Select(attrs={'class': 'form-control form-select mb-1 js-example-basic-single', 'text':'ref'}),
label=''
widget=forms.Select(attrs={'class': 'form-control form-select mb-1 js-example-basic-single', 'text':'ref',}),
label='',
empty_label="Please choose a Reference ..." ,

)

# ref = forms.ModelChoiceField(
# queryset=Reference.objects.all(),
# widget=forms.Select(attrs={'class': 'form-control form-select mb-3 js-states js-example-basic-single'}),
# label='ref'
# )
page_from = forms.IntegerField(label='', required=False)
page_to = forms.IntegerField(label='', required=False)
parent_pars = forms.CharField(widget=forms.Textarea(attrs={'style': 'height: 140px;'}), label='Consulted Paragraphs (Private, for NLP project)', required=False)
parent_pars = forms.CharField(widget=forms.Textarea(attrs={'style': 'height: 60px;', 'placeholder': 'Consulted Paragraphs (Private, for NLP project)' }), label='', required=False)
#parent_pars = forms.Textarea(attrs={'class': 'form-control mb-3', 'style': 'height: 120px', 'placeholder':'Please copy and paste the paragraphs you consulted into this field for each reference.'})


Expand All @@ -309,6 +312,9 @@ def add_fields(self, form, index):
super().add_fields(form, index)
form.fields['ref'].widget.attrs['class'] = 'form-control form-select mb-1 p-1 js-example-basic-single'
form.fields['page_from'].widget.attrs['class'] = 'form-control mb-1 p-1'
form.fields['page_from'].widget.attrs['placeholder'] = 'p_from'
form.fields['page_to'].widget.attrs['placeholder'] = 'p_to'

form.fields['page_to'].widget.attrs['class'] = 'form-control mb-1 p-1'
form.fields['parent_pars'].widget.attrs['class'] = 'form-control mb-1 p-1'

Expand All @@ -318,23 +324,32 @@ def add_fields(self, form, index):


ReferenceFormSet5 = forms.formset_factory(ReferenceWithPageForm, formset=BaseReferenceFormSet, extra=5, max_num=5, can_delete=True, can_order=True)

ReferenceFormSet10 = forms.formset_factory(ReferenceWithPageForm, formset=BaseReferenceFormSet, extra=10, max_num=10, can_delete=True, can_order=True)
#ReferenceFormSet = forms.formset_factory(ReferenceWithPageForm, extra=2, can_delete=True,)


class SeshatCommentPartForm2(forms.Form):
comment_text = forms.CharField(label='SubComment Text (Public)', widget=forms.Textarea(attrs={'class': 'form-control mb-1 p-0', 'style': 'height: 200px',}))
comment_text = forms.CharField(label='', widget=forms.Textarea(attrs={'class': 'form-control mb-1 p-1', 'style': 'height: 300px', 'placeholder': 'SubDescription Text (Public)'}))

formset = ReferenceFormSet2(prefix='refs')
comment_order = forms.IntegerField(label='Do NOT Change This Number: ', required=False,)
formset.management_form # Include the management form

class SeshatCommentPartForm5(forms.Form):
comment_text = forms.CharField(label='Comment Textu', widget=forms.Textarea(attrs={'class': 'form-control mb-1 p-0', 'style': 'height: 200px',}))
comment_text = forms.CharField(label='', widget=forms.Textarea(attrs={'class': 'form-control mb-1 p-0', 'style': 'height: 200px',}))

formset = ReferenceFormSet5(prefix='refs')
comment_order = forms.IntegerField(label='Do NOT Change This Number: ', required=False,)
formset.management_form # Include the management form

class SeshatCommentPartForm10(forms.Form):
comment_text = forms.CharField(label='', widget=forms.Textarea(attrs={'class': 'form-control mb-1 p-0', 'style': 'height: 200px',}))

formset = ReferenceFormSet10(prefix='refs')
comment_order = forms.IntegerField(label='Do NOT Change This Number: ', required=False,)
formset.management_form # Include the management form

CommentPartFormSet = forms.formset_factory(SeshatCommentPartForm2, extra=2)


Expand Down Expand Up @@ -431,3 +446,46 @@ class Meta:
unique_together = ("variable_name", "section_name", "subsection_name")

# VarHierFormSet = formset_factory(VariablehierarchyForm, extra=10)


############


class ReferenceWithPageForm_UPGRADE(forms.Form):
ref = forms.ModelChoiceField(
queryset=Reference.objects.all(),
widget=forms.Select(attrs={'class': 'form-control form-select mb-1 js-example-basic-single'}),
label=''
)
page_from = forms.IntegerField(label='', required=False)
page_to = forms.IntegerField(label='', required=False)
parent_pars = forms.CharField(widget=forms.Textarea(attrs={'style': 'height: 140px;'}), label='Consulted Paragraphs (UPGRADED) (Private, for NLP project)', required=False)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_method = 'post'
self.helper.add_input(Submit('submit', 'Submit'))



ReferenceFormSet2_UPGRADE = formset_factory(ReferenceWithPageForm_UPGRADE, extra=1)

class SeshatCommentPartForm2_UPGRADE(forms.Form):
comment_text = forms.CharField(label='SubComment Text (Public)', widget=forms.Textarea(attrs={'class': 'form-control mb-1', 'style': 'height: 200px'}))
references_formset = ReferenceFormSet2_UPGRADE(prefix='refs')
#formset = ReferenceFormSet2_UPGRADE(prefix='refs')
comment_order = forms.IntegerField(label='Do NOT Change This Number:', required=False)
references_formset.management_form # Include the management form


#formset.management_form # Include the management form

# class SeshatCommentPartWithReferencesForm_UPGRADE(forms.Form):
# comment_part_form = SeshatCommentPartForm2_UPGRADE()
# references_formset = ReferenceFormSet2_UPGRADE()
# references_formset.management_form # Include the management form


#formset = ReferenceFormSet2(prefix='refs')
#comment_order = forms.IntegerField(label='Do NOT Change This Number: ', required=False,)
Loading

0 comments on commit 509f316

Please sign in to comment.