Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide participants from other regforms #6176

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

vtran99
Copy link
Contributor

@vtran99 vtran99 commented Feb 8, 2024

Request to add new privacy setting for Participant List: setting to hide participants from other registration forms.
This PR replaces #6167, the code is done following previous review from Duarte.

Note: I will fix the privacy_test.py once we agree on the code change, thanks.

@@ -18,6 +18,7 @@
{% endcall %}
{% if regforms %}
{% call form_fieldset(_('Registration forms')) %}
{{ form_row(form.hide_participants_from_other_forms) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now the toggle is below the save button, which is not ideal. we also don't have a perfect solution for this, but I think if you place the save button just below this toggle it would make more sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last thing here - it's still not ideal but we think it looks better if this input goes under the regform table

image

(we will probably do some UI improvements here on a later PR anyway, but if you could switch these two around here it'd be nice)

@duartegalvao
Copy link
Member

Overall the changes look good! You can go ahead and fix the tests (and maybe add some to test this new behavior). When you're done let me know so I can take a closer look / test the PR

@vtran99
Copy link
Contributor Author

vtran99 commented Feb 13, 2024

I fixed privacy tests and added some for the new feature, please check.

Copy link
Member

@duartegalvao duartegalvao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall quite nice, just needs a few minor code style-related changes

once the test coverage is improved this is pretty much good to go 😊

"""Check whether the user is registered in the event.

If registration, return True only if user is registered in the same regform as registration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the reST format for docstrings

Suggested change
If registration, return True only if user is registered in the same regform as registration.
:param registration: A registration. If defined, return True only if user is registered in the same regform as registration.

~Registration.is_deleted,
~RegistrationForm.is_deleted))
if registration:
query = query.filter(Registration.registration_form == registration.registration_form)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it seems you're only using the registration to get its regform.. Why not just pass the regform itself? It would also make the docstring a bit clearer

Comment on lines 153 to 159
registrations = sorted(_deduplicate_reg_data(_process_registration(reg, column_names)
for reg in query if reg.is_publishable(is_participant)),
for reg in query
if reg.is_publishable(user,
hide_participants_from_other_forms)),
key=lambda reg: tuple(x['text'].lower() for x in reg['columns']))
return {'headers': headers,
'rows': registrations,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this statement is starting to become a bit unreadable with all the identation. i'd suggest to format it like this:

        registrations = _deduplicate_reg_data(_process_registration(reg, column_names)
                                              for reg in query
                                              if reg.is_publishable(user, hide_participants_from_other_forms))
        return {'headers': headers,
                'rows': sorted(registrations, key=lambda reg: tuple(x['text'].lower() for x in reg['columns'])),
                'show_checkin': any(registration['checked_in'] for registration in registrations),
                'num_participants': query.count()}

(theres plenty of places where we do the sorting in the return statement, moreover the order doesn't matter for show_checkin)

Comment on lines +344 to +345
return db.or_(db.and_(is_participant, cls.registration_form.has(publish_registrations_participants=mode)),
db.and_(~is_participant, cls.registration_form.has(publish_registrations_public=mode)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though this works, it gets quite confusing when you're trying to track where is_participant comes from

for readability, i'd put the function definition after is_participant is defined.. or if that looks awkward, maybe pass it explicitly to the function

query = query.filter(reg_alias.registration_form_id == cls.registration_form_id)
is_participant = query.exists()
else:
is_participant = db.text('false')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_participant = db.text('false')
is_participant = literal(False)

literal from sqlalchemy is preferred for this

Comment on lines 55 to +56
@pytest.mark.usefixtures('dummy_reg')
def test_registration_visibility(dummy_event, dummy_regform):
def test_registration_visibility(dummy_event, dummy_regform, dummy_user):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional, but it might be a good idea to parametrize this test, specially if you're adding more test cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants