-
Notifications
You must be signed in to change notification settings - Fork 364
feat: add gravatar configuration to cfp settings #2128
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
Open
sarafarajnasardi
wants to merge
13
commits into
fossasia:dev
Choose a base branch
from
sarafarajnasardi:2119
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a83f54c
feat: add gravatar configuration to cfp settings
sarafarajnasardi 1d6cf7e
fix: update question toggles JS to prevent unintended AJAX calls
sarafarajnasardi 0ffa5dc
fix: resolve TemplateSyntaxError in avatar.html
sarafarajnasardi 4cd21f4
Merge branch 'dev' into 2119
mariobehling 822d883
fix: resolve TemplateSyntaxError in avatar.html
sarafarajnasardi bebe2e0
test: add coverage for enable_gravatar property
sarafarajnasardi 7fc0439
refactor: use avatar_url property in avatar template
sarafarajnasardi 9e756f1
Merge branch 'enext' into 2119
sarafarajnasardi 37fc342
Merge branch 'dev' into 2119
sarafarajnasardi 9a62283
Merge branch 'dev' into 2119
mariobehling 4bc6e0e
fix: clean up PR review feedback and tighten scope
sarafarajnasardi 8a525a7
fix: making ui consistent
sarafarajnasardi 3723875
Merge branch 'dev' into 2119
Saksham-Sirohi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,107 @@ | ||
| import pytest | ||
| from eventyay.base.models import CfP | ||
| from eventyay.orga.forms.cfp import CfPSettingsForm | ||
|
|
||
| @pytest.mark.django_db | ||
| def test_cfp_enable_gravatar_default_true(event): | ||
| """Test that enable_gravatar defaults to True when not set""" | ||
| # Event fixture creates an event. Check if it has CfP. | ||
| if not hasattr(event, 'cfp'): | ||
| CfP.objects.create(event=event) | ||
sarafarajnasardi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| cfp = event.cfp | ||
| # Should default to True | ||
| assert cfp.enable_gravatar | ||
|
|
||
| @pytest.mark.django_db | ||
| def test_cfp_enable_gravatar_explicit_false(event): | ||
| """Test that enable_gravatar can be explicitly set to False""" | ||
| if not hasattr(event, 'cfp'): | ||
| CfP.objects.create(event=event) | ||
|
|
||
sarafarajnasardi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cfp = event.cfp | ||
| cfp.settings['cfp_enable_gravatar'] = False | ||
| cfp.save() | ||
|
|
||
| # Should return False when explicitly set | ||
| assert not cfp.enable_gravatar | ||
|
|
||
| @pytest.mark.django_db | ||
| def test_cfp_enable_gravatar_explicit_true(event): | ||
| """Test that enable_gravatar can be explicitly set to True""" | ||
| if not hasattr(event, 'cfp'): | ||
| CfP.objects.create(event=event) | ||
|
|
||
sarafarajnasardi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cfp = event.cfp | ||
| cfp.settings['cfp_enable_gravatar'] = True | ||
| cfp.save() | ||
|
|
||
| # Should return True when explicitly set | ||
| assert cfp.enable_gravatar | ||
|
|
||
| @pytest.mark.django_db | ||
| def test_cfp_enable_gravatar_missing_key(event): | ||
| """Test enable_gravatar behavior when key is missing from settings""" | ||
| if not hasattr(event, 'cfp'): | ||
| CfP.objects.create(event=event) | ||
|
|
||
sarafarajnasardi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cfp = event.cfp | ||
|
|
||
| # Ensure key doesn't exist | ||
| if 'cfp_enable_gravatar' in cfp.settings: | ||
| del cfp.settings['cfp_enable_gravatar'] | ||
| cfp.save() | ||
|
|
||
| # Should still default to True | ||
| assert cfp.enable_gravatar | ||
|
|
||
| @pytest.mark.django_db | ||
| def test_cfp_settings_form_toggle_gravatar(event): | ||
| """Test that CfPSettingsForm correctly updates enable_gravatar setting""" | ||
| from django_scopes import scope | ||
|
|
||
| if not hasattr(event, 'cfp'): | ||
| CfP.objects.create(event=event) | ||
|
|
||
sarafarajnasardi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cfp = event.cfp | ||
|
|
||
| with scope(event=event): | ||
| # Instantiate form to get fields and initial values | ||
| form_inst = CfPSettingsForm(obj=event, read_only=False) | ||
| form_data = {} | ||
|
|
||
| # Populate data for all fields, especially required ones | ||
| for name, field in form_inst.fields.items(): | ||
| # Prefer explicit initial data | ||
| if name in form_inst.initial: | ||
| form_data[name] = form_inst.initial[name] | ||
| # Then field-level initial | ||
| elif field.initial is not None: | ||
| form_data[name] = field.initial | ||
| # Then first choice for ChoiceFields (if required) | ||
| elif field.required and hasattr(field, 'choices') and field.choices: | ||
| form_data[name] = field.choices[0][0] | ||
| # Then boolean defaults | ||
| elif isinstance(field, (pytest.importorskip("django.forms").BooleanField)): | ||
| form_data[name] = False | ||
|
|
||
| # Test setting to False | ||
| form_data['cfp_enable_gravatar'] = False | ||
|
|
||
| form = CfPSettingsForm(obj=event, read_only=False, data=form_data) | ||
|
|
||
| if form.is_valid(): | ||
| form.save() | ||
| assert not cfp.enable_gravatar | ||
| else: | ||
| pytest.fail(f"Form invalid: {form.errors}") | ||
|
|
||
| # Test setting back to True | ||
| form_data['cfp_enable_gravatar'] = True | ||
| form = CfPSettingsForm(obj=event, read_only=False, data=form_data) | ||
|
|
||
| if form.is_valid(): | ||
| form.save() | ||
| assert cfp.enable_gravatar | ||
| else: | ||
| pytest.fail(f"Form invalid: {form.errors}") | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.