Skip to content
Snippets Groups Projects
Verified Commit 8875202b authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add icon field to OAuth application model

parent 58de54a9
No related branches found
No related tags found
1 merge request!885Resolve "OpenID Login process: Visually indicate login flow"
......@@ -775,6 +775,7 @@ class OAuthApplicationForm(forms.ModelForm):
model = OAuthApplication
fields = (
"name",
"icon",
"client_id",
"client_secret",
"client_type",
......
# Generated by Django 3.2.11 on 2022-01-08 13:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0030_user_attributes'),
]
operations = [
migrations.AddField(
model_name='oauthapplication',
name='icon',
field=models.ImageField(blank=True, help_text='This image will be shown as icon in the authorization flow. It should be squared.', null=True, upload_to='', verbose_name='Icon'),
),
]
......@@ -1248,6 +1248,15 @@ class OAuthApplication(AbstractApplication):
blank=True,
)
icon = models.ImageField(
verbose_name=_("Icon"),
blank=True,
null=True,
help_text=_(
"This image will be shown as icon in the authorization flow. It should be squared."
),
)
def allows_grant_type(self, *grant_types: set[str]) -> bool:
allowed_grants = get_site_preferences()["auth__oauth_allowed_grants"]
......
......@@ -6,7 +6,7 @@
{% block page_title %}{% blocktrans %}Register OAuth2 Application{% endblocktrans %}{% endblock %}
{% block content %}
<form method="post">
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{% form form=form %}{% endform %}
{% include "core/partials/save_button.html" %}
......
......@@ -22,6 +22,18 @@
</a>
<table class="responsive-table">
<tbody>
<tr>
<th>{% trans "Icon" %}</th>
<td>
{% if application.icon %}
<div class="application-circle materialboxed z-depth-2">
<img src="{{ application.icon.url }}" alt="{{ oauth_application.name }}" class="hundred-percent">
</div>
{% else %}
{% endif %}
</td>
</tr>
<tr>
<th>
{% trans "Client id" %}
......
......@@ -6,7 +6,7 @@
{% block page_title %}{% blocktrans %}Edit OAuth2 Application{% endblocktrans %}{% endblock %}
{% block content %}
<form method="post">
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{% form form=form %}{% endform %}
{% include "core/partials/save_button.html" %}
......
......@@ -12,8 +12,13 @@
</a>
<div class="collection">
{% for application in applications %}
<a class="collection-item" href="{% url "oauth2_application" application.id %}">
{{ application.name }}
<a class="collection-item avatar" href="{% url "oauth2_application" application.id %}">
{% if application.icon %}
<img src="{{ application.icon.url }}" alt="{{ application.name }}" class="circle">
{% endif %}
<span class="title">
{{ application.name }}
</span>
</a>
{% empty %}
<div class="collection-item flow-text">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment