Пример #1
0
    def SynchronizationComplete(self, serviceRecord):
        root = os.path.join(USER_DATA_FILES, serviceRecord.ExternalID)
        if not os.path.exists(root):
            return

        user_folder = os.path.join(USER_DATA_FILES, serviceRecord.ExternalID)
        user_hash = uuid.uuid4().hex
        zipf_name = os.path.join(USER_DATA_FILES, user_hash)
        shutil.make_archive(zipf_name, 'zip', user_folder)

        # To reduce disk usage delete all data except the result archive
        # but keep root structure cause user is not yed disconnected
        shutil.rmtree(user_folder, ignore_errors=True)
        self._ensure_user_root_exists(serviceRecord.ExternalID)

        file_url = "{}/download/{}".format(WEB_ROOT, user_hash)

        host = socket.gethostname()
        if PRIMARY_HOST_NAME != host:
            # send zip archive to the http server node
            with open(zipf_name + ".zip", 'rb') as file:
                requests.post(file_url, data=file)

        context = {
            "url": file_url
        }
        message, plaintext_message = generate_message_from_template("email/data_download.html", context)
        send_email(serviceRecord.ExternalID, "Your Aerobia files", message, plaintext_message=plaintext_message)
Пример #2
0
def payments_send_confirmation(request, email):
    dashboard_url = request.build_absolute_uri(reverse("dashboard"))
    from tapiriik.web.email import generate_message_from_template, send_email
    message, plaintext_message = generate_message_from_template(
        "email/payment_confirm.html", {"url": dashboard_url})
    send_email(email,
               "Thanks, %s!" % request.POST["first_name"],
               message,
               plaintext_message=plaintext_message)
Пример #3
0
def payments_claim_initiate(request, user, email):
    payment = Payments.GetPayment(email=email)
    if payment is None:
        return False
    claim_code = Payments.GenerateClaimCode(user, payment)
    reclaim_url = request.build_absolute_uri(reverse("payments_claim_return", kwargs={"code": claim_code}))
    from tapiriik.web.email import generate_message_from_template, send_email
    message, plaintext_message = generate_message_from_template("email/payment_reclaim.html", {"url":reclaim_url})
    send_email(email, "Reclaim your payment on tapiriik.sfrunners.club", message, plaintext_message=plaintext_message)
    return True
Пример #4
0
def payments_claim_initiate(request, user, email):
    payment = Payments.GetPayment(email=email)
    if payment is None:
        return False
    claim_code = Payments.GenerateClaimCode(user, payment)
    reclaim_url = request.build_absolute_uri(reverse("payments_claim_return", kwargs={"code": claim_code}))
    from tapiriik.web.email import generate_message_from_template, send_email
    message, plaintext_message = generate_message_from_template("email/payment_reclaim.html", {"url":reclaim_url})
    send_email(email, "Reclaim your payment on tapiriik.com", message, plaintext_message=plaintext_message)
    return True
Пример #5
0
def payments_send_confirmation(request, email):
    dashboard_url = request.build_absolute_uri(reverse("dashboard"))
    from tapiriik.web.email import generate_message_from_template, send_email

    message, plaintext_message = generate_message_from_template("email/payment_confirm.html", {"url": dashboard_url})
    send_email(email, "Thanks, %s!" % request.POST["first_name"], message, plaintext_message=plaintext_message)
Пример #6
0
		connected_services_names = ", ".join(connected_services_names[:-1]) + " and " + connected_services_names[-1] + " accounts"
	else:
		connected_services_names = connected_services_names[0] + " accounts"

	subscription_days = round((expired_payment["Expiry"] - expired_payment["Timestamp"]).total_seconds() / (60 * 60 * 24))
	subscription_fuzzy_time_map = {
		(0, 8): "few days",
		(8, 31): "few weeks",
		(31, 150): "few months",
		(150, 300): "half a year",
		(300, 999): "year"
	}
	subscription_fuzzy_time = [v for k,v in subscription_fuzzy_time_map.items() if k[0] <= subscription_days and k[1] > subscription_days][0]

	activity_records = db.activity_records.find_one({"UserID": connected_user["_id"]})
	total_distance_synced = None
	if activity_records:
		total_distance_synced = sum([x["Distance"] for x in activity_records["Activities"] if x["Distance"]])
		total_distance_synced = math.floor(total_distance_synced/1000 / 100) * 100

	context = {
		"account_list": connected_services_names,
		"subscription_days": subscription_days,
		"subscription_fuzzy_time": subscription_fuzzy_time,
		"distance": total_distance_synced
	}
	message, plaintext_message = generate_message_from_template("email/payment_renew.html", context)
	send_email(expired_payment["Email"], "tapiriik automatic synchronization expiry", message, plaintext_message=plaintext_message)
	db.payments.update({"_id": expired_payment["_id"]}, {"$set": {"ReminderEmailSent": True}})
	print("...sent")
Пример #7
0
    ][0]

    activity_records = db.activity_records.find_one(
        {"UserID": connected_user["_id"]})
    total_distance_synced = None
    if activity_records:
        total_distance_synced = sum([
            x["Distance"] for x in activity_records["Activities"]
            if x["Distance"]
        ])
        total_distance_synced = math.floor(
            total_distance_synced / 1000 / 100) * 100

    context = {
        "account_list": connected_services_names,
        "subscription_days": subscription_days,
        "subscription_fuzzy_time": subscription_fuzzy_time,
        "distance": total_distance_synced
    }
    message, plaintext_message = generate_message_from_template(
        "email/payment_renew.html", context)
    send_email(expired_payment["Email"],
               "tapiriik automatic synchronization expiry",
               message,
               plaintext_message=plaintext_message)
    db.payments.update({"_id": expired_payment["_id"]},
                       {"$set": {
                           "ReminderEmailSent": True
                       }})
    print("...sent")