Commit 79e80338 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Make it possible to hide name from ev member list

parent 831abc2a
......@@ -106,6 +106,7 @@ class UserProfileForm(BootstrapModelFormMixin, forms.ModelForm):
"email",
"avatar",
"bio",
"show_ev_member",
"timezone",
"homepage",
"matrix_nick",
......
# Generated by Django 3.0.10 on 2021-05-06 14:39
from django.db import migrations, models
import martor.models
class Migration(migrations.Migration):
dependencies = [
('bid_main', '0045_merge_20210329_1645'),
]
operations = [
migrations.AddField(
model_name='user',
name='show_ev_member',
field=models.BooleanField(default=True, help_text='Indicate if the user should be listed in the ev member list.'),
),
migrations.AlterField(
model_name='user',
name='bio',
field=martor.models.MartorField(blank=True, help_text='Public information about the user', verbose_name='Description'),
),
]
......@@ -439,6 +439,11 @@ class User(AbstractBaseUser, PermissionsMixin):
blank=True, max_length=200, verbose_name="Liberapay Username"
)
show_ev_member = models.BooleanField(
default=True,
help_text=_("Indicate if the user should be listed in the ev member list."),
)
@property
def twitter_nick_link(self):
if self.twitter_nick == "":
......@@ -511,6 +516,10 @@ class User(AbstractBaseUser, PermissionsMixin):
"""
return self.roles.badges()
def is_ev_member(self) -> bool:
"""Return true if the user is a member of the ev-members group"""
return "ev-members" in [role.name for role in self.roles.all()]
def get_full_name(self):
"""
Returns the full name.
......
......@@ -51,6 +51,6 @@ class EvMembersView(View):
def get(self, request: HttpRequest) -> JsonResponse:
users = []
for user in models.User.objects.filter(roles__name__exact="ev-active"):
for user in models.User.objects.filter(roles__name__exact="ev-members",show_ev_member=True):
users.append(user.full_name)
return JsonResponse({"members": users})
......@@ -57,6 +57,16 @@
</div>
{{ form.avatar.errors }}
{% if user.is_ev_member %}
<hr />
<div class="form-check">
{{ form.show_ev_member }}
<label class="ml-2 form-check-label" for="{{ form.show_ev_member.id_for_label }}">
Show my name on the <a href="https://ev.kde.org/members">KDE e.V. member list</a>.
</label>
</div>
{% endif %}
<hr />
<h4 class="mt-1">Information for profile pages</h4>
......@@ -65,7 +75,7 @@
<div class="form-check">
{{ form.public_profile }}
<label class="form-check-label" for="{{ form.public_profile.id_for_label }}">
<label class="ml-2 form-check-label" for="{{ form.public_profile.id_for_label }}">
{{ form.public_profile.label }}
</label>
<br />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment