Remove shariff

Browsers (specially on mobile) have integrated share buttons
This commit is contained in:
Roland Geider
2024-01-15 16:41:37 +01:00
parent b2ec394619
commit 7688df25e2
16 changed files with 5 additions and 149 deletions

View File

@@ -19,7 +19,6 @@
"jquery": "^3.7.1",
"masonry-layout": "^4.2.2",
"popper.js": "^1.16.1",
"shariff": "^3.3.0",
"yarn": "^1.22.21"
},
"scripts": {

View File

@@ -132,32 +132,6 @@ function getProfileField(field) {
return result;
}
function wgerToggleReadOnlyAccess() {
$('#toggle-ro-access').click(function (e) {
var $shariffModal;
var roAccess;
e.preventDefault();
roAccess = getProfileField('ro_access');
// Update user profile
setProfileField('ro_access', !roAccess);
// Hide and show appropriate divs
$shariffModal = $('#shariffModal');
if (!roAccess) {
$shariffModal.find('.shariff').removeClass('d-none');
$shariffModal.find('.noRoAccess').addClass('d-none');
} else {
$shariffModal.find('.shariff').addClass('d-none');
$shariffModal.find('.noRoAccess').removeClass('d-none');
}
});
}
/*
Open a modal dialog for form editing
*/

View File

@@ -2,9 +2,7 @@
{% load i18n wger_extras django_bootstrap_breadcrumbs %}
{% block template %}
{% if show_shariff %}
{% include 'misc/fragments/shariff_modal.html' %}
{% endif %}
{% if trainer_identity %}
@@ -34,15 +32,6 @@
{% endblock %}
</div>
{% if show_shariff %}
<button type="button"
class="btn btn-link btn-sm float-end"
data-bs-toggle="modal"
data-bs-target="#shariffModal"
title="{% trans 'Share' %}">
<span class="{% fa_class 'share-alt' %}"></span>
</button>
{% endif %}
</div>
</div>

View File

@@ -1,8 +1,5 @@
{% extends "template.html" %}{% load i18n wger_extras django_bootstrap_breadcrumbs %}
{% block template %}
{% if show_shariff %}
{% include 'misc/fragments/shariff_modal.html' %}
{% endif %}
{% if trainer_identity %}
@@ -29,16 +26,6 @@
{% block options %}
{% endblock %}
{% if show_shariff %}
<button type="button"
class="btn btn-light btn-sm"
data-bs-toggle="modal"
data-bs-target="#shariffModal">
<span class="glyphicon glyphicon-retweet"></span>
{% trans "Share" %}
</button>
{% endif %}
</div>
</div>
</div>

View File

@@ -1,37 +0,0 @@
{% load i18n wger_extras %}
<div class="modal fade" id="shariffModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{% translate "Share this page" %}</h4>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="shariff {% if is_owner and not owner_user.userprofile.ro_access %}d-none{% endif %}"
data-lang="{{ language.short_name }}"
data-orientation="horizontal"
data-button-style="icon"
data-services="[&quot;facebook&quot;,&quot;twitter&quot;,&quot;whatsapp&quot;,&quot;telegram&quot;,&quot;info&quot;]"></div>
{% if owner_user %}
<div
class="noRoAccess {% if user.is_authenticated and is_owner and owner_user.userprofile.ro_access %}d-none{% endif %}">
<p>{% blocktranslate %}Before you share links on social media you need to allow external
access.{% endblocktranslate %}</p>
<p>
<a href="{% url 'core:user:preferences' %}" id="toggle-ro-access"
class="btn btn-success btn-sm">
<span class="{% fa_class 'check' %}"></span>
{% translate "That's done here" %}
</a>
</p>
</div>
{% endif %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">{% translate "Close" %}</button>
</div>
</div>
</div>
</div>

View File

@@ -49,8 +49,6 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'yarn/bootstrap-compiled.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-custom.css' %}">
<link rel="stylesheet" type="text/css"
href="{% static 'yarn/shariff/dist/shariff.min.css' %}">
<link rel="stylesheet" type="text/css"
href="{% static 'fontawesomefree/css/all.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'react/main.css' %}" id="react-css">
@@ -86,9 +84,6 @@
// Initialise the hook to reload the main-content
wgerLoadMaincontent();
// Check for RO-access before allowing sharing
wgerToggleReadOnlyAccess();
});
</script>
@@ -226,6 +221,5 @@
</div>
</footer>
<script src="{% static 'yarn/shariff/dist/shariff.min.js' %}"></script>
</body>
</html>

View File

@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# This file is part of wger Workout Manager.
#
# wger Workout Manager is free software: you can redistribute it and/or modify

View File

@@ -67,26 +67,6 @@ class WeightLogAccessTestCase(WgerTestCase):
self.assertEqual(response.status_code, 403)
class CalendarShareButtonTestCase(WgerTestCase):
"""
Test that the share button is correctly displayed and hidden
"""
def test_share_button(self):
url = reverse('manager:workout:calendar', kwargs={'username': 'admin'})
response = self.client.get(url)
self.assertFalse(response.context['show_shariff'])
self.user_login('admin')
response = self.client.get(url)
self.assertTrue(response.context['show_shariff'])
self.user_login('test')
response = self.client.get(url)
self.assertFalse(response.context['show_shariff'])
class CalendarAccessTestCase(WgerTestCase):
"""
Test accessing the calendar page

View File

@@ -296,7 +296,6 @@ class WorkoutLogDetailView(DetailView, LoginRequiredMixin):
context['workout_log'] = workout_log
context['owner_user'] = self.owner_user
context['is_owner'] = is_owner
context['show_shariff'] = is_owner
return context
@@ -337,7 +336,6 @@ def calendar(request, username=None, year=None, month=None):
context['is_owner'] = is_owner
context['impressions'] = WorkoutSession.IMPRESSION
context['month_list'] = WorkoutLog.objects.filter(user=user).dates('date', 'month')
context['show_shariff'] = is_owner and user.userprofile.ro_access
return render(request, 'calendar/month.html', context)
@@ -357,6 +355,5 @@ def day(request, username, year, month, day):
context['date'] = date
context['owner_user'] = user
context['is_owner'] = is_owner
context['show_shariff'] = is_owner and user.userprofile.ro_access
return render(request, 'calendar/day.html', context)

View File

@@ -113,7 +113,6 @@ def view(request, pk):
template_data['token'] = token
template_data['is_owner'] = is_owner
template_data['owner_user'] = user
template_data['show_shariff'] = is_owner
template_data['download_form'] = WorkoutScheduleDownloadForm()
return render(request, 'schedule/view.html', template_data)

View File

@@ -120,7 +120,6 @@ def view(request, pk):
'token': token,
'is_owner': is_owner,
'owner_user': user,
'show_shariff': is_owner,
}
return render(request, 'workout/view.html', context)

View File

@@ -301,8 +301,8 @@ class Ingredient(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
raise ValidationError(
_(
'The total energy ({energy}kcal) is not the approximate sum of the '
'energy provided by protein, carbohydrates and fat ({energy_calculated}kcal '
'+/-{energy_approx}%)'.format(
'energy provided by protein, carbohydrates and fat ({energy_calculated}kcal'
' +/-{energy_approx}%)'.format(
energy=self.energy,
energy_calculated=energy_calculated,
energy_approx=self.ENERGY_APPROXIMATION
@@ -473,6 +473,7 @@ class Ingredient(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
logger.info(f'Got JSONDecodeError from OFF: {e}')
return None
if result['status'] != OFF_SEARCH_PRODUCT_FOUND:
logger.info('Product not found')
return None
product = result['product']

View File

@@ -82,14 +82,6 @@ class IngredientListView(ListView):
language = load_language()
return Ingredient.objects.accepted().filter(language=language).only('id', 'name')
def get_context_data(self, **kwargs):
"""
Pass additional data to the template
"""
context = super(IngredientListView, self).get_context_data(**kwargs)
context['show_shariff'] = True
return context
def view(request, pk, slug=None):
context = {}
@@ -108,7 +100,6 @@ def view(request, pk, slug=None):
}
)
context['show_shariff'] = True
return render(request, 'ingredient/view.html', context)

View File

@@ -83,7 +83,6 @@ def processor(request):
or '/contact' in request.get_full_path() \
or '/api/v2' in request.get_full_path():
context['active_tab'] = constants.SOFTWARE_TAB
context['show_shariff'] = True
elif '/exercise/' in request.get_full_path():
context['active_tab'] = constants.WORKOUT_TAB

View File

@@ -159,7 +159,6 @@ def overview(request, username=None):
context = {
'is_owner': is_owner,
'owner_user': user,
'show_shariff': False,
}
return render(request, 'overview.html', context)

View File

@@ -2,11 +2,6 @@
# yarn lockfile v1
"@fortawesome/fontawesome-free@^5.8.2":
version "5.14.0"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.14.0.tgz#a371e91029ebf265015e64f81bfbf7d228c9681f"
integrity sha512-OfdMsF+ZQgdKHP9jUbmDcRrP0eX90XXrsXIdyjLbkmSBzmMXPABB8eobUJtivaupucYaByz6WNe1PI1JuYm3qA==
"@types/jquery@^2.0.32":
version "2.0.54"
resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-2.0.54.tgz#d7999245f77c3fab5d84e7d32b8a6c20bfd1f072"
@@ -331,7 +326,7 @@ iconv-lite@0.6:
resolved "https://registry.yarnpkg.com/internmap/-/internmap-2.0.1.tgz#33d0fa016185397549fb1a14ea3dbe5a2949d1cd"
integrity sha512-Ujwccrj9FkGqjbY3iVoxD1VV+KdZZeENx0rphrtzmRXbFvkFO88L80BL/zeSIguX/7T+y8k04xqtgWgS5vxwxw==
jquery@>=1.7, jquery@^3.4.1, jquery@^3.7.1:
jquery@>=1.7, jquery@^3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.7.1.tgz#083ef98927c9a6a74d05a6af02806566d16274de"
integrity sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==
@@ -373,14 +368,6 @@ rw@1:
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
shariff@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/shariff/-/shariff-3.3.0.tgz#567b23f929298442a593af2f30258bd13ef4d587"
integrity sha512-k8aITaDpbdIlun3mJ/SlfSRrc5vvyl4wjsJ0gTrclCNo/wemCVhhY7wEk5HqOy4y/3msVDEarwuF/SU2j7+Auw==
dependencies:
"@fortawesome/fontawesome-free" "^5.8.2"
jquery "^3.4.1"
yarn@^1.22.21:
version "1.22.21"
resolved "https://registry.yarnpkg.com/yarn/-/yarn-1.22.21.tgz#1959a18351b811cdeedbd484a8f86c3cc3bbaf72"