Ejemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields['template_file_upload'].widget = CustomButtonFileWidget()

        # This hidden form field is updated by JavaScript code in the
        # customized admin template file:
        #   turkle/templates/admin/turkle/project/change_form.html
        self.fields['filename'].widget = HiddenInput()

        self.fields['assignments_per_task'].label = 'Assignments per Task'
        self.fields['assignments_per_task'].help_text = 'This parameter sets the default ' + \
            'number of Assignments per Task for new Batches of Tasks.  Changing this ' + \
            'parameter DOES NOT change the number of Assignments per Task for already ' + \
            'published batches of Tasks.'
        self.fields['custom_permissions'].label = 'Restrict access to specific Groups of Workers '
        self.fields['html_template'].label = 'HTML template text'
        limit = str(get_turkle_template_limit())
        self.fields['html_template'].help_text = 'You can edit the template text directly, ' + \
            'Drag-and-Drop a template file onto this window, ' + \
            'or use the "Choose File" button below. Maximum size is ' + limit + ' KB.'
        byte_limit = str(get_turkle_template_limit(True))
        self.fields['html_template'].widget.attrs['data-parsley-maxlength'] = byte_limit
        self.fields['html_template'].widget.attrs['data-parsley-group'] = 'html_template'

        initial_ids = [str(id)
                       for id in get_groups_with_perms(self.instance).values_list('id', flat=True)]
        self.fields['worker_permissions'].initial = initial_ids
Ejemplo n.º 2
0
 def test_too_large_template(self):
     limit = get_turkle_template_limit(True)
     template = 'a' * limit + '<textarea>'
     with self.assertRaisesMessage(ValidationError, 'Template is too large'):
         Project(
             html_template=template,
         ).clean()
Ejemplo n.º 3
0
 def test_too_large_template(self):
     limit = get_turkle_template_limit(True)
     template = 'a' * limit + '<textarea>'
     with self.assertRaisesMessage(ValidationError, 'Template is too large'):
         Project(
             html_template=template,
         ).clean()