Private
Public Access
1
0

instantplans

This commit is contained in:
2023-08-14 21:41:35 +02:00
parent 87a65cd5f8
commit cd9fba9121
5 changed files with 21 additions and 3 deletions

View File

@@ -1715,6 +1715,8 @@ class InstantPlan(models.Model):
price = models.IntegerField(default=0, verbose_name="Price in EURO") price = models.IntegerField(default=0, verbose_name="Price in EURO")
url = models.CharField(max_length=250, blank=True, url = models.CharField(max_length=250, blank=True,
verbose_name="Link to page with more information") verbose_name="Link to page with more information")
private = models.BooleanField(default=False,
verbose_name="Hidden, personal")
def __str__(self): # pragma: no cover def __str__(self): # pragma: no cover
return self.name return self.name
@@ -1753,6 +1755,7 @@ class InstantPlanForm(ModelForm):
'hoursperweek', 'hoursperweek',
'sessionsperweek', 'sessionsperweek',
'yaml', 'yaml',
'private'
] ]

View File

@@ -30,6 +30,9 @@
<p>Created by: {{ plan.owner.first_name }} {{ plan.owner.last_name }}</p> <p>Created by: {{ plan.owner.first_name }} {{ plan.owner.last_name }}</p>
<p>Plan length: {{ plan.duration }} days</p> <p>Plan length: {{ plan.duration }} days</p>
<p>{{ plan.description }}</p> <p>{{ plan.description }}</p>
{% if plan.private %}
<p><em>Private</em></p>
{% endif %}
{% if plan.target %} {% if plan.target %}
<p>What the plan will achieve: {{ plan.target }}</p> <p>What the plan will achieve: {{ plan.target }}</p>
{% endif %} {% endif %}

Binary file not shown.

View File

@@ -848,7 +848,12 @@ def rower_register_view(request):
weightcategory = form.cleaned_data['weightcategory'] weightcategory = form.cleaned_data['weightcategory']
adaptiveclass = form.cleaned_data['adaptiveclass'] adaptiveclass = form.cleaned_data['adaptiveclass']
nextpage = request.POST['next'] nextpage = request.POST['next']
theuser = User.objects.create_user(username, password=password) try:
theuser = User.objects.create_user(username, password=password)
except:
messages.error(request, "This user name already exists, choose another one")
url = reverse('rower_register_view')
return HttpResponseRedirect(url)
theuser.first_name = first_name theuser.first_name = first_name
theuser.last_name = last_name theuser.last_name = last_name
theuser.email = email theuser.email = email

View File

@@ -2849,8 +2849,15 @@ def rower_select_instantplan(request, id=0):
r = getrequestrower(request, userid=id) r = getrequestrower(request, userid=id)
# get and present available plans # get and present available plans
ips = InstantPlan.objects.all().order_by( ips = InstantPlan.objects.filter(private=False)
"name", "sessionsperweek", "hoursperweek", "duration", "id")
if not request.user.is_anonymous:
ips2 = InstantPlan.objects.filter(owner=request.user)
ips = ips | ips2
ips = ips.order_by("private", "name", "sessionsperweek", "hoursperweek", "duration", "id")
breadcrumbs = [ breadcrumbs = [
{ {