-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
from django import forms | ||
|
||
from experiments.models import Experiment | ||
from participants.models import Participant | ||
from .models import Comment | ||
|
||
|
||
class CommentForm(forms.ModelForm): | ||
class Meta: | ||
model = Comment | ||
fields = ['participant', 'comment'] | ||
fields = ["participant", "comment"] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.fields['participant'].widget = forms.HiddenInput() | ||
self.fields["participant"].widget = forms.HiddenInput() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ def as_admin(sb, admin_user, live_server): | |
def as_leader(sb, django_user_model, live_server): | ||
username = "test_user" | ||
password = "test_user" | ||
user = django_user_model.objects.create_user(username=username, password=password) | ||
user = django_user_model.objects.create_user(username=username, password=password, name='Test Leader') | ||
sb.open(live_server.url + "/login") | ||
# sb.click('#djHideToolBarButton') | ||
sb.type("#id_username", username) | ||
|
@@ -46,6 +46,7 @@ def sample_participant(db): | |
participant = Participant.objects.create( | ||
email="[email protected]", | ||
name="Baby McBaby", | ||
sex=Participant.Sex.UNKNOWN, | ||
parent_first_name="Parent", | ||
parent_last_name="McParent", | ||
birth_date=date(2020, 1, 1), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def test_participant_add_comment(sb, live_server, as_leader, sample_experiment, sample_participant): | ||
sample_experiment.leaders.add(as_leader) | ||
sb.open(live_server.url + "/participants") | ||
sb.click(f"a:contains('{sample_participant.name}')") | ||
sb.click("a:contains('new comment')") | ||
sb.click("textarea") | ||
sb.type("textarea", "hello this is a comment") | ||
sb.click("button:contains(Send)") | ||
|
||
sb.assert_text_not_visible("button:contains(Send)") | ||
sb.assert_text_visible("hello this is a comment") | ||
sb.assert_text(as_leader.name, "#participant-comments") |