-
Notifications
You must be signed in to change notification settings - Fork 11
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
Use tomselect #421
Closed
Closed
Use tomselect #421
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1bfce28
Use tomselect
frcroth 770f739
Lint
frcroth a52204b
Merge branch 'upstream-main' into tomselect
frcroth 94a46a1
Add user profile to get display name field for tomselect
frcroth 49cabf4
Fix sth
frcroth afe4038
Fix tests
frcroth 5dec7e2
Remove markdown.util.etree
frcroth 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 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
72 changes: 72 additions & 0 deletions
72
myhpi/core/migrations/0009_userprofile_for_minutes_display_name.py
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,72 @@ | ||
# Generated by Django 4.0.7 on 2023-11-21 19:05 | ||
|
||
import django.db.models.deletion | ||
import modelcluster.fields | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
def create_user_profiles(apps, schema_editor): | ||
User = apps.get_model("auth", "User") | ||
for user in User.objects.all(): | ||
UserProfile = apps.get_model("core", "UserProfile") | ||
display_name = user.first_name + " " + user.last_name | ||
UserProfile.objects.create(user=user, display_name=display_name) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("core", "0008_remove_footer_column_4"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="UserProfile", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
("display_name", models.CharField(blank=True, max_length=255)), | ||
( | ||
"user", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL | ||
), | ||
), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name="minutes", | ||
name="author", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.PROTECT, | ||
related_name="author", | ||
to="core.userprofile", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="minutes", | ||
name="moderator", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.PROTECT, | ||
related_name="moderator", | ||
to="core.userprofile", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="minutes", | ||
name="participants", | ||
field=modelcluster.fields.ParentalManyToManyField( | ||
related_name="minutes", to="core.userprofile" | ||
), | ||
), | ||
migrations.RunPython(create_user_profiles), | ||
] |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't really like the proxy models and generally prefer substituting the user model as a whole. However, this seems to be a bit tricky for existing projects (https://docs.djangoproject.com/en/4.2/topics/auth/customizing/#changing-to-a-custom-user-model-mid-project).