This commit is contained in:
sahama 2024-08-05 16:17:10 +03:30
parent 307ac359a2
commit b852161ed6
6 changed files with 37 additions and 17 deletions

View file

@ -55,21 +55,25 @@ class ApplicationForm(forms.ModelForm):
class ApplicationCreateForm(forms.ModelForm):
class Meta:
model = Application
fields = ['name',
'client_id',
'client_secret',
fields = [
'name',
# 'client_id',
# 'client_secret',
# 'available_scopes_list',
# 'authorization_grant_type',
'redirect_uris',
'post_logout_redirect_uris']
readonly_fields = ['client_id', 'client_secret']
# 'post_logout_redirect_uris'
]
class ApplicationUpdateForm(forms.ModelForm):
name = forms.CharField(disabled=True)
client_id = forms.CharField(disabled=True)
client_secret = forms.CharField(disabled=True)
class Meta:
model = Application
fields = [
'name',
'client_id',
'client_secret',
# 'authorization_grant_type',

View file

@ -22,6 +22,9 @@ class ApplicationCreateView(CreateView):
def form_valid(self, form):
form.instance.user = self.request.user
form.instance.client_type = Application.CLIENT_PUBLIC
form.instance.algorithm = Application.RS256_ALGORITHM
form.instance.hash_client_secret = False
form.instance.authorization_grant_type = Application.GRANT_AUTHORIZATION_CODE
return super().form_valid(form)

View file

@ -3,8 +3,8 @@
{% load crispy_forms_tags %}
{% load jalali_tags %}
{% block title %}Application: create{% endblock %}
{% block page_title %}Application: create{% endblock %}
{% block title %}Application Register{% endblock %}
{% block page_title %}Application Register{% endblock %}
{% block content %}
<form action="{{ request.get_full_path }}" method="post" enctype="multipart/form-data" novalidate>
@ -15,6 +15,7 @@
<div class="col-12">
<div class="grid">
<div class="d-flex justify-content-end">
<a href="{% url 'gooyal_oauth2:application_list' %}" class="btn btn-danger ms-2">انصراف</a>
<input class="btn btn-success ms-2" type="submit" value="ثبت" name="save"/>
</div>
</div>

View file

@ -3,8 +3,19 @@
{% load crispy_forms_tags %}
{% load jalali_tags %}
{% block title %}Application: detail{% endblock %}
{% block page_title %}Application: detail{% endblock %}
{% block title %}Application Detail: {{ object }}{% endblock %}
{% block page_title %}Application Detail: {{ object }}{% endblock %}
{% block page_action %}
<div class="me-2">
<a href="{% url 'gooyal_oauth2:application_update' object.pk %}">
<div class="btn btn-success">
<span class="bi bi-gear-fill"></span>
</div>
</a>
</div>
{% endblock %}
{% block content %}
<p>application: {{ object.name }}!</p>

View file

@ -5,8 +5,8 @@
{% load tags %}
{% block title %}Application: list{% endblock %}
{% block page_title %}Application: list{% endblock %}
{% block title %}Application List{% endblock %}
{% block page_title %}Application List{% endblock %}
{% block page_action %}
{% include "include/filter_action.html" %}
<div class="me-2">

View file

@ -3,8 +3,8 @@
{% load crispy_forms_tags %}
{% load jalali_tags %}
{% block title %}Application: update{% endblock %}
{% block page_title %}Application: update{% endblock %}
{% block title %}Application Update: {{ object }}{% endblock %}
{% block page_title %}Application Update: {{ object }}{% endblock %}
{% block content %}
<form action="{{ request.get_full_path }}" method="post" enctype="multipart/form-data" novalidate>
@ -15,6 +15,7 @@
<div class="col-12">
<div class="grid">
<div class="d-flex justify-content-end">
<a href="{% url "gooyal_oauth2:application_detail" object.pk %}" class="btn btn-danger ms-2">انصراف</a>
<input class="btn btn-success ms-2" type="submit" value="ثبت" name="save"/>
</div>
</div>