added option to number poll cadidates

This commit is contained in:
jsangmeister 2019-11-12 09:20:10 +01:00 committed by FinnStutzenstein
parent 8d77c0495b
commit 90b04366b5
7 changed files with 35 additions and 5 deletions

View File

@ -10,6 +10,7 @@ export interface AssignmentWithoutNestedModels extends BaseModelWithAgendaItemAn
default_poll_description: string; default_poll_description: string;
tags_id: number[]; tags_id: number[];
attachments_id: number[]; attachments_id: number[];
number_poll_candidates: boolean;
} }
/** /**

View File

@ -301,6 +301,13 @@
}}</mat-error> }}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<!-- Number poll candidates -->
<div>
<mat-checkbox formControlName="number_poll_candidates">
<span translate>Number poll candidates</span>
</mat-checkbox>
</div>
<!-- TODO searchValueSelector: Parent --> <!-- TODO searchValueSelector: Parent -->
</form> </form>
</mat-card> </mat-card>

View File

@ -193,7 +193,8 @@ export class AssignmentDetailComponent extends BaseViewComponent implements OnIn
open_posts: [1, [Validators.required, Validators.min(1)]], open_posts: [1, [Validators.required, Validators.min(1)]],
agenda_create: [''], agenda_create: [''],
agenda_parent_id: [], agenda_parent_id: [],
agenda_type: [''] agenda_type: [''],
number_poll_candidates: [false]
}); });
this.candidatesForm = formBuilder.group({ this.candidatesForm = formBuilder.group({
userId: null userId: null

View File

@ -129,6 +129,11 @@ class Migration(migrations.Migration):
), ),
preserve_default=False, preserve_default=False,
), ),
migrations.AddField(
model_name="assignment",
name="number_poll_candidates",
field=models.BooleanField(default=False),
),
migrations.AlterField( migrations.AlterField(
model_name="assignment", model_name="assignment",
name="poll_description_default", name="poll_description_default",

View File

@ -153,6 +153,11 @@ class Assignment(RESTModelMixin, AgendaItemWithListOfSpeakersMixin, models.Model
Mediafiles as attachments for this assignment. Mediafiles as attachments for this assignment.
""" """
number_poll_candidates = models.BooleanField(default=False)
"""
Controls whether the candidates in polls for this assignment should be numbered or listed with bullet points.
"""
class Meta: class Meta:
default_permissions = () default_permissions = ()
permissions = ( permissions = (

View File

@ -169,6 +169,7 @@ class AssignmentSerializer(ModelSerializer):
"agenda_parent_id", "agenda_parent_id",
"tags", "tags",
"attachments", "attachments",
"number_poll_candidates",
) )
validators = (posts_validator,) validators = (posts_validator,)

View File

@ -42,10 +42,6 @@ class CreateAssignment(TestCase):
Tests basic creation of assignments. Tests basic creation of assignments.
""" """
def setUp(self):
self.client = APIClient()
self.client.login(username="admin", password="admin")
def test_simple(self): def test_simple(self):
response = self.client.post( response = self.client.post(
reverse("assignment-list"), reverse("assignment-list"),
@ -54,6 +50,7 @@ class CreateAssignment(TestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
assignment = Assignment.objects.get() assignment = Assignment.objects.get()
self.assertEqual(assignment.title, "test_title_ef3jpF)M329f30m)f82") self.assertEqual(assignment.title, "test_title_ef3jpF)M329f30m)f82")
self.assertEqual(assignment.number_poll_candidates, False)
def test_with_tags_and_mediafiles(self): def test_with_tags_and_mediafiles(self):
Tag.objects.create(name="test_tag") Tag.objects.create(name="test_tag")
@ -75,6 +72,19 @@ class CreateAssignment(TestCase):
self.assertTrue(assignment.tags.exists()) self.assertTrue(assignment.tags.exists())
self.assertTrue(assignment.attachments.exists()) self.assertTrue(assignment.attachments.exists())
def test_number_poll_candidates(self):
response = self.client.post(
reverse("assignment-list"),
{
"title": "test_title_EFBhGQkQciwZtjSc7BVy",
"open_posts": 1,
"number_poll_candidates": True,
},
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
assignment = Assignment.objects.get()
self.assertEqual(assignment.number_poll_candidates, True)
class CandidatureSelf(TestCase): class CandidatureSelf(TestCase):
""" """