Merge tag 'v4.21' into develop
added image width height to image model for FB
This commit is contained in:
@@ -584,6 +584,8 @@ class GraphImage(models.Model):
|
||||
filename = models.CharField(default='',max_length=150,blank=True,null=True)
|
||||
creationdatetime = models.DateTimeField()
|
||||
workout = models.ForeignKey(Workout)
|
||||
width = models.IntegerField(default=1200)
|
||||
height = models.IntegerField(default=600)
|
||||
|
||||
def __str__(self):
|
||||
return self.filename
|
||||
|
||||
@@ -9,8 +9,12 @@
|
||||
{% block og_description %}{{ workout.name }}
|
||||
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
|
||||
{% block og_image %}
|
||||
<meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" />
|
||||
<meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" />
|
||||
<meta property="og:image:width" content="{{ graph.width }}" />
|
||||
<meta property="og:image:height" content="{{ graph.height }}" />
|
||||
<meta property="og:image:secure_url" content="https://rowsandall.com/{{ graph.filename |spacetohtml }}" />
|
||||
<meta property="og:image:width" content="{{ graph.width }}" />
|
||||
<meta property="og:image:height" content="{{ graph.height }}" />
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<h1>{{ workout.name }}</h1>
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
{% block og_image %}
|
||||
{% for graph in graphs1 %}
|
||||
<meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" />
|
||||
<meta property="og:image:width" content="{{ graph.width }}" />
|
||||
<meta property="og:image:height" content="{{ graph.height }}" />
|
||||
<meta property="og:image:secure_url" content="https://rowsandall.com/{{ graph.filename |spacetohtml }}" />
|
||||
<meta property="og:image:width" content="{{ graph.width }}" />
|
||||
<meta property="og:image:height" content="{{ graph.height }}" />
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% block image_src %}
|
||||
|
||||
@@ -10,6 +10,8 @@ from rowers.tasks import (
|
||||
|
||||
from rowers.models import GraphImage
|
||||
|
||||
from PIL import Image
|
||||
|
||||
import numpy as np
|
||||
import yaml
|
||||
import argparse
|
||||
@@ -181,10 +183,16 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
|
||||
title,hrpwrdata,
|
||||
plotnr,imagename)
|
||||
|
||||
|
||||
try:
|
||||
width,height = Image.open(fullpathimagename).size
|
||||
except:
|
||||
width = 1200
|
||||
height = 600
|
||||
|
||||
i = GraphImage(workout=w,
|
||||
creationdatetime=timezone.now(),
|
||||
filename=fullpathimagename)
|
||||
filename=fullpathimagename,
|
||||
width=width,height=height)
|
||||
i.save()
|
||||
|
||||
return i.id
|
||||
|
||||
@@ -8,6 +8,7 @@ import pytz
|
||||
import operator
|
||||
import warnings
|
||||
import urllib
|
||||
from PIL import Image
|
||||
from numbers import Number
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.db.models import Q
|
||||
@@ -4594,6 +4595,15 @@ def workout_view(request,id=0):
|
||||
raise Http404("Not allowed to view this workout")
|
||||
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
r = Rower.objects.get(id=row.user.id)
|
||||
u = User.objects.get(id=r.user.id)
|
||||
|
||||
@@ -5229,6 +5239,15 @@ def workout_geeky_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
form = WorkoutForm(instance=row)
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
# check if user is owner of this workout
|
||||
|
||||
if (checkworkoutuser(request.user,row)==False):
|
||||
@@ -5670,6 +5689,15 @@ def workout_advanced_view(request,id=0,message="",successmessage=""):
|
||||
raise Http404("Workout doesn't exist")
|
||||
form = WorkoutForm(instance=row)
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
# check if user is owner of this workout
|
||||
|
||||
if (checkworkoutuser(request.user,row)==False):
|
||||
@@ -6113,6 +6141,15 @@ def workout_export_view(request,id=0, message="", successmessage=""):
|
||||
|
||||
form = WorkoutForm(instance=row)
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
# check if user is owner of this workout
|
||||
|
||||
if (checkworkoutuser(request.user,row)==False):
|
||||
@@ -6253,6 +6290,15 @@ def workout_comment_view(request,id=0):
|
||||
form = WorkoutCommentForm()
|
||||
|
||||
g = GraphImage.objects.filter(workout=w).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
if (len(g)<=3):
|
||||
return render(request,
|
||||
@@ -6372,6 +6418,16 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
raise Http404("Workout doesn't exist")
|
||||
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# check if user is owner of this workout
|
||||
|
||||
comments = WorkoutComment.objects.filter(workout=row)
|
||||
@@ -6593,6 +6649,15 @@ def workout_edit_view_navionics(request,id=0,message="",successmessage=""):
|
||||
raise Http404("Workout doesn't exist")
|
||||
|
||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||
for i in g:
|
||||
try:
|
||||
width,height = Image.open(i.filename).size
|
||||
i.width = width
|
||||
i.height = height
|
||||
i.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
# check if user is owner of this workout
|
||||
|
||||
comments = WorkoutComment.objects.filter(workout=row)
|
||||
@@ -7774,6 +7839,14 @@ def graphs_view(request):
|
||||
def graph_show_view(request,id):
|
||||
try:
|
||||
g = GraphImage.objects.get(id=id)
|
||||
try:
|
||||
width,height = Image.open(g.filename).size
|
||||
g.width = width
|
||||
g.height = height
|
||||
g.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
w = Workout.objects.get(id=g.workout.id)
|
||||
r = Rower.objects.get(id=w.user.id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user