diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 87895291..4a082f35 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -18,6 +18,7 @@ from iso8601 import ParseError import numpy import json +from json.decoder import JSONDecodeError from rowsandall_app.settings import ( C2_CLIENT_ID, C2_REDIRECT_URI, C2_CLIENT_SECRET diff --git a/rowers/dataprep.py b/rowers/dataprep.py index bbfd6ffb..33f961be 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -1782,6 +1782,11 @@ def delete_strokedata(id): dirname = 'media/strokedata_{id}.parquet.gz'.format(id=id) try: shutil.rmtree(dirname) + except OSError: + try: + os.remove(dirname) + except FileNotFoundError: + pass except FileNotFoundError: pass diff --git a/rowers/forms.py b/rowers/forms.py index 46de978c..bbd919b8 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -115,7 +115,6 @@ class EmailForm(forms.Form): lastname = forms.CharField(max_length=255) email = forms.EmailField() subject = forms.CharField(max_length=255) - botcheck = forms.CharField(max_length=5) message = forms.CharField() disqualificationreasons = ( diff --git a/rowers/templates/email.html b/rowers/templates/email.html index 474c3765..86fd7b2e 100644 --- a/rowers/templates/email.html +++ b/rowers/templates/email.html @@ -3,115 +3,134 @@ {% block main %}

Contact us through email

+
    -
  • - {% if form.errors %} -

    - Please correct the error{{ form.errors|pluralize }} below. -

    - {% endif %} - - -
    {% csrf_token %} - - - - - -
    - - - - - -
    - - - - - - -
    - - - -
    - - - -
    - - - - - -
    - Do you want to send me an email? - - -
    - - - -
    - -
    -
    +
  • + {% if form.errors %} +

    + Please correct the error{{ form.errors|pluralize }} below. +

    + {% endif %} + + +
    {% csrf_token %} +

    + + + + + +
    + + + + + +
    + + + + + + +
    + + + +
    + + + +
    + + + + + +
    + + + +
    + +
    +

    +
  • -

    Bug reporting, feature requests

    - -

    - Bug reports and feature requests can be done through our BitBucket page. Please check on the following link if your bug or issue is a known one. Feel free to file any feature request. -

      -
    • BitBucket Issue list (click here to go report an issue or request a feature)
    • -
    -

    +

    Bug reporting, feature requests

    + +

    + Bug reports and feature requests can be done through our BitBucket page. Please check on the following link if your bug or issue is a known one. Feel free to file any feature request. +

      +
    • BitBucket Issue list (click here to go report an issue or request a feature)
    • +
    +

  • -

    Facebook Group

    - -

    We run a facebook group where you can post questions and report problems, - especially if you think the wider user community benefits from the answers.

    -
      -
    • https://www.facebook.com/groups/rowsandall/
    • -
    -
  • +

    Facebook Group

    -
  • -

    Twitter

    - -

    You can also check me on Twitter: -

      -
    • https://twitter.com/rowsandall -
    - When the site is down, this is the appropriate channel to look for apologies, updates, and offer help. -

    -
  • +

    We run a facebook group where you can post questions and report problems, + especially if you think the wider user community benefits from the answers.

    +
      +
    • https://www.facebook.com/groups/rowsandall/
    • +
    + -
  • -

    Rowsandall s.r.o.

    - -

    Rowsandall s.r.o.
    - Nové sady 988/2
    - 602 00 Brno
    - Czech Republic
    - IČ: 070 48 572
    - DIČ: CZ 070 48 572 (Nejsme plátce DPH)
    - Datová schránka: 7897syr
    - Email: info@rowsandall.com
    - The company is registered in the business register at the - Regional Court in Brno (Společnost je zapsána v obchodním rejstříku vedeném u Krajského soudu v Brně, oddíl C, vložka 105845)
    -

    +
  • +

    Twitter

    -
  • -
-{% endblock %} +

You can also check me on Twitter: +

    +
  • https://twitter.com/rowsandall +
+ When the site is down, this is the appropriate channel to look for apologies, updates, and offer help. +

+ -{% block sidebar %} -{% include 'menu_help.html' %} -{% endblock %} +
  • +

    Rowsandall s.r.o.

    - +

    Rowsandall s.r.o.
    + Nové sady 988/2
    + 602 00 Brno
    + Czech Republic
    + IČ: 070 48 572
    + DIČ: CZ 070 48 572 (Nejsme plátce DPH)
    + Datová schránka: 7897syr
    + Email: info@rowsandall.com
    + The company is registered in the business register at the + Regional Court in Brno (Společnost je zapsána v obchodním rejstříku vedeném u Krajského soudu v Brně, oddíl C, vložka 105845)
    +

    + +
  • + + {% endblock %} + + {% block sidebar %} + {% include 'menu_help.html' %} + {% endblock %} + + {% block scripts %} + + + {% endblock %} diff --git a/rowers/templates/paymentconfirmationemail.html b/rowers/templates/paymentconfirmationemail.html index 0bc62f45..1d97167c 100644 --- a/rowers/templates/paymentconfirmationemail.html +++ b/rowers/templates/paymentconfirmationemail.html @@ -7,6 +7,17 @@ Thank you. We have received the payment of € {{ amount }} for Rowsandall related services.

    +

    + With your contribution, you are helping to keep this service to the rowing community + running. As the founder and developer of the Rowsandall.com site I am very interested + to know what you think of Rowsandall.com, as well as suggestions for improvements. +

    + +

    + So don't hesitate to respond to this email and let me know. I will read and respond to each + email. +

    +

    Please contact our customer service by replying to this email if you have any further questions regarding the payment. @@ -16,4 +27,3 @@ Best Regards, the Rowsandall Team

    {% endblock %} - diff --git a/rowers/templates/plantrialwelcome.html b/rowers/templates/plantrialwelcome.html new file mode 100644 index 00000000..5f588c43 --- /dev/null +++ b/rowers/templates/plantrialwelcome.html @@ -0,0 +1,31 @@ +{% extends "emailbase.html" %} + +{% block body %} +

    Dear {{ first_name }},

    + +

    + Welcome on the trial for the Self-Coach plan. +

    +

    +As the developer of the Rowsandall.com site I am very interested to know what you think of Rowsandall.com. Especially, I'd like to understand how you started using the site, what you are looking for, and what you think could be improved. +

    +

    +The Self-Coach functionality allows you to create training plans and sessions for you and your training group. Feel free to contact me any time you need help. +

    +

    +I'd also love to hear a bit about your rowing background. +

    + +

    + So don't hesitate to respond to this email and let me know. I will read and respond to each + email. +

    +

    +Thank you very much for your help and for supporting rowsandall.com. +

    + + +

    + Best Regards, the Rowsandall Team +

    +{% endblock %} diff --git a/rowers/templates/protrialewelcome.html b/rowers/templates/protrialewelcome.html new file mode 100644 index 00000000..a7bf7892 --- /dev/null +++ b/rowers/templates/protrialewelcome.html @@ -0,0 +1,33 @@ +{% extends "emailbase.html" %} + +{% block body %} +

    Dear {{ first_name }},

    + +

    + Welcome on the trial for the Pro plan. +

    +

    +As the developer of the Rowsandall.com site I am very interested to know +what you think of Rowsandall.com. +Especially, I'd like to understand how you started using the site, +what you are looking for, and what you think could be improved. +

    + +

    +I'd also love to hear a bit about your rowing background. +

    + +

    + So don't hesitate to respond to this email and let me know. I will read and respond to each + email. +

    + +

    +Thank you very much for your help and for supporting rowsandall.com. +

    + + +

    + Best Regards, the Rowsandall Team +

    +{% endblock %} diff --git a/rowers/templates/subscription_update_email.html b/rowers/templates/subscription_update_email.html index d805d0d5..6f0cee59 100644 --- a/rowers/templates/subscription_update_email.html +++ b/rowers/templates/subscription_update_email.html @@ -5,22 +5,34 @@

    Thank you. We have received the payment of € {{ amount }} for - your updated Rowsandall subscription. - You are now on the Rowsandall paid plan "{{ planname }}". + your updated Rowsandall subscription. + You are now on the Rowsandall paid plan "{{ planname }}".

    +

    + With your contribution, you are helping to keep this service to the rowing community + running. As the founder and developer of the Rowsandall.com site I am very interested + to know what you think of Rowsandall.com, as well as suggestions for improvements. +

    + +

    + So don't hesitate to respond to this email and let me know. I will read and respond to each + email. +

    + {% if recurring=='recurring' %}

    + Some more information about the subscription. The subscription cost is €{{ price }} per year. Your next charge is due on {{ end_of_billing_period }}. We will charge you automatically - on that date. + on that date.

    The subscription will keep running until you change or stop it. At any point in time you can change the automatically renewing subscription to a "one year only" subscription through the upgrade page. On this page, you can also - upgrade your subscription. + upgrade your subscription.

    {% else %} @@ -28,7 +40,7 @@ The price of the subscription is €{{ price }}. You have paid €{{ amount }} as a prorated cost of your upgrade. This one year subscription will automatically end on {{ end_of_billing_period }}. You can - renew your subscription after that. + renew your subscription after that.

    @@ -60,4 +72,3 @@ Best Regards, the Rowsandall Team

    {% endblock %} - diff --git a/rowers/views/statements.py b/rowers/views/statements.py index 1f1e700d..9f09bccc 100644 --- a/rowers/views/statements.py +++ b/rowers/views/statements.py @@ -158,7 +158,8 @@ from rowsandall_app.settings import ( RUNKEEPER_CLIENT_ID,RUNKEEPER_REDIRECT_URI,RUNKEEPER_CLIENT_SECRET, TP_CLIENT_ID,TP_REDIRECT_URI,TP_CLIENT_KEY,TP_CLIENT_SECRET, BRAINTREE_MERCHANT_ID,BRAINTREE_PUBLIC_KEY,BRAINTREE_PRIVATE_KEY, - PAYMENT_PROCESSING_ON + PAYMENT_PROCESSING_ON, + RECAPTCHA_SITE_KEY, RECAPTCHA_SITE_SECRET ) #from rowers.tasks_standalone import addcomment2 @@ -1073,28 +1074,39 @@ def add_defaultfavorites(r): f.save() return 1 + # Shows email form and sends it if submitted def sendmail(request): if request.method == 'POST': + # test recaptcha + response_string = request.POST.get('g-recaptcha-response') + # replace below with settings + recaptcha_secret = RECAPTCHA_SITE_SECRET + url = 'https://www.google.com/recaptcha/api/siteverify' + data = { + 'secret':recaptcha_secret, + 'response': response_string, + } + response = requests.post(url,data=data,verify=True) + success = False + if response.status_code == 200: + success = response.json().get('success') + form = EmailForm(request.POST) - if form.is_valid(): + if form.is_valid() and success: firstname = form.cleaned_data['firstname'] lastname = form.cleaned_data['lastname'] email = form.cleaned_data['email'] - subject = form.cleaned_data['subject'] - botcheck = form.cleaned_data['botcheck'].lower() + subject = 'Rowsandall Contact Form:'+form.cleaned_data['subject'] message = form.cleaned_data['message'] - if botcheck == 'yes': - try: - fullemail = firstname + " " + lastname + " " + "<" + email + ">" - send_mail(subject, message, fullemail, ['info@rowsandall.com']) - return HttpResponseRedirect('/rowers/email/thankyou/') - except: - return HttpResponseRedirect('/rowers/email/') - else: - messages.error(request,'You have to answer YES to the question') - return HttpResponseRedirect('/rowers/email/') + fullemail = firstname + " " + lastname + " " + "<" + email + ">" + send_mail(subject, message, fullemail, ['info@rowsandall.com']) + return HttpResponseRedirect('/rowers/email/thankyou/') else: + if not success: + messages.error(request,'Bots are not welcome') + else: + messages.error(request,'Something went wrong. Please try again') return HttpResponseRedirect('/rowers/email/') else: return HttpResponseRedirect('/rowers/email/') diff --git a/rowers/views/userviews.py b/rowers/views/userviews.py index a8aea814..710fd771 100644 --- a/rowers/views/userviews.py +++ b/rowers/views/userviews.py @@ -13,23 +13,30 @@ def start_trial_view(request): messages.error(request,'You do not qualify for a trial') url = '/rowers/paidplans' return HttpResponseRedirect(url) - + r.protrialexpires = datetime.date.today()+datetime.timedelta(13) r.save() url = reverse('workouts_view') messages.info(request,'We have started your 14 day trial period') - + subject2 = "User started Pro Trial" message2 = "User Started Pro Trial.\n" message2 += request.user.email + "\n" message2 += "User name: "+request.user.username - + send_mail(subject2, message2, 'Rowsandall Server ', ['roosendaalsander@gmail.com']) - + + send_template_email('Rowsandall ', + [r.user.email], + 'Welcome to the Rowsandall Pro Trial', + 'protrialewelcome.html', + {'first_name':r.user.first_name, + 'last_name':r.user.last_name}) + return HttpResponseRedirect(url) @login_required() @@ -40,7 +47,7 @@ def start_plantrial_view(request): messages.error(request,'You do not qualify for a trial') url = '/rowers/paidplans' return HttpResponseRedirect(url) - + r.plantrialexpires = datetime.date.today()+datetime.timedelta(13) r.protrialexpires = datetime.date.today()+datetime.timedelta(13) r.save() @@ -48,16 +55,23 @@ def start_plantrial_view(request): url = reverse('workouts_view') messages.info(request,'We have started your 14 day trial period') - + subject2 = "User started Plan Trial" message2 = "User Started Plan Trial.\n" message2 += request.user.email + "\n" message2 += "User name: "+request.user.username - + send_mail(subject2, message2, 'Rowsandall Server ', ['roosendaalsander@gmail.com']) - + + send_template_email('Rowsandall ', + [r.user.email], + 'Welcome to the Rowsandall Self-Coach Trial', + 'plantrialwelcome.html', + {'first_name':r.user.first_name, + 'last_name':r.user.last_name}) + return HttpResponseRedirect(url) # Page where user can manage his favorite charts @@ -79,7 +93,7 @@ def rower_favoritecharts_view(request,userid=0): FavoriteChartFormSet = formset_factory(FavoriteForm,formset=BaseFavoriteFormSet,extra=0) if aantal==0: FavoriteChartFormSet = formset_factory(FavoriteForm,formset=BaseFavoriteFormSet,extra=1) - + if request.method == 'POST': favorites_formset = FavoriteChartFormSet(request.POST) @@ -115,7 +129,7 @@ def rower_favoritecharts_view(request,userid=0): messages.error(request,message) else: favorites_formset = FavoriteChartFormSet(initial=favorites_data) - + context = { 'favorites_formset':favorites_formset, @@ -123,8 +137,8 @@ def rower_favoritecharts_view(request,userid=0): 'rower':r, } - - + + return render(request,'favoritecharts.html',context) # page where user sets his export settings @@ -154,7 +168,7 @@ def rower_exportsettings_view(request,userid=0): 'name': 'Export Settings' } ] - + return render(request, 'rower_exportsettings.html', {'form':form, 'rower':r, @@ -367,7 +381,7 @@ def rower_prefs_view(request,userid=0,message=""): 'rower':r, }) - + # Revoke an app that you granted access through the API. # this views is called when you press a button on the User edit page # the button is only there when you have granted access to an app @@ -401,7 +415,7 @@ def rower_update_empower_view( r = getrower(request.user) except Rower.DoesNotExist: raise Http404("Rower doesn't exist") - + if request.method == 'POST' and 'daterange' in request.POST: dateform = DateRangeForm(request.POST) if dateform.is_valid(): @@ -416,7 +430,7 @@ def rower_update_empower_view( 'startdate':startdate, 'enddate':enddate, }) - + if request.method == 'POST' and 'workouts' in request.POST: form = WorkoutMultipleCompareForm(request.POST) @@ -424,7 +438,7 @@ def rower_update_empower_view( cd = form.cleaned_data workouts = cd['workouts'] workoutdicts = [] - + for w in workouts: if w.user != r: message = "You can only alter your own workouts" @@ -440,7 +454,7 @@ def rower_update_empower_view( messages.error(request,message) else: - + workoutdict = { 'id':w.id, 'boattype':w.boattype, @@ -454,7 +468,7 @@ def rower_update_empower_view( w.workoutsource = 'speedcoach2corrected' w.save() - + job = myqueue(queuelow,handle_update_empower, request.user.email,workoutdicts, debug=False, @@ -479,7 +493,7 @@ def rower_update_empower_view( workoutsource='speedcoach2', user=r, ).order_by("-date","-starttime") - + form = WorkoutMultipleCompareForm() form.fields["workouts"].queryset = workouts # GET request = prepare form @@ -491,5 +505,3 @@ def rower_update_empower_view( 'form':form, 'rower':r }) - - diff --git a/rowsandall_app/settings.py b/rowsandall_app/settings.py index 2df72fc8..283aa476 100644 --- a/rowsandall_app/settings.py +++ b/rowsandall_app/settings.py @@ -494,3 +494,13 @@ try: CELERY = CFG['use_celery'] except KeyError: CELERY = False + + +# Recaptcha + +try: + RECAPTCHA_SITE_KEY = CFG['recaptcha_site_key'] + RECAPTCHA_SITE_SECRET = CFG['recaptcha_site_secret'] +except KeyError: + RECAPTCHA_SITE_KEY = '' + RECAPTCHA_SITE_SECRET = '' diff --git a/rowsandall_app/settings_dev.py b/rowsandall_app/settings_dev.py index ad4c57c1..d40f8ca2 100644 --- a/rowsandall_app/settings_dev.py +++ b/rowsandall_app/settings_dev.py @@ -60,7 +60,7 @@ DEBUG = True TEMPLATES[0]['OPTIONS']['debug'] = DEBUG -ALLOWED_HOSTS = ['localhost'] +ALLOWED_HOSTS = ['localhost','127.0.0.1'] # INSTALLED_APPS += ['debug_toolbar',] diff --git a/templates/newbase.html b/templates/newbase.html index 3b6f4e2a..885e3f90 100644 --- a/templates/newbase.html +++ b/templates/newbase.html @@ -48,6 +48,7 @@ {% block meta %} {% endblock %}
    +