Disable fetch button during timeout period
This commit is contained in:
parent
0f30b61445
commit
b2927151ef
2 changed files with 20 additions and 5 deletions
|
|
@ -4,19 +4,25 @@
|
|||
{% block actions %}
|
||||
<section class="section form__section--last">
|
||||
<fieldset class="fieldset form__fieldset">
|
||||
{% include "components/form/confirm-button.html" %}
|
||||
|
||||
<a class="link button button--primary" href="{% url 'accounts:password-change' %}">
|
||||
{% trans "Change password" %}
|
||||
</a>
|
||||
|
||||
{% if favicon_task_allowed %}
|
||||
<a class="link button button--primary" href="{% url 'accounts:settings:favicon' %}">
|
||||
{% trans "Fetch favicons" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<button class="button button--primary button--disabled" disabled>
|
||||
{% trans "Fetch favicons" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
<a class="link button button--primary" href="{% url 'accounts:settings:integrations' %}">
|
||||
{% trans "Third party integrations" %}
|
||||
</a>
|
||||
|
||||
{% include "components/form/confirm-button.html" %}
|
||||
</fieldset>
|
||||
</section>
|
||||
{% endblock actions %}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from django.core.cache import cache
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic.edit import FormView, ModelFormMixin
|
||||
|
||||
|
|
@ -19,6 +20,14 @@ class SettingsView(ModelFormMixin, FormView):
|
|||
self.object = self.get_object()
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
return {
|
||||
**context,
|
||||
"favicon_task_allowed": not cache.get(f"{self.request.user}-favicon-task"),
|
||||
}
|
||||
|
||||
def get_object(self, **kwargs):
|
||||
return self.request.user
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue