Esempio n. 1
0
def post_user_forgotpassword():
    email = request.json.get('email')
    user = User.query.filter_by(email=email).first()
    if not user:
        return jsonify({
            'status': 'error',
            'message': 'No user with that email address found',
        })
    else:
        if 'sizesquirrel' in user.provider_id:
            token = user.get_token()
            # send email
            send_email(
                "SizeSquirrel - Reset Your Password",
                current_app.config['ADMINS'][0], [user.email],
                render_template("emails/reset_password.txt", token=token),
                render_template("emails/reset_password.html", token=token))
            return jsonify({
                'status':
                "success",
                'message':
                'An email has been sent with password reset instructions'
            })
        else:
            return jsonify({
                'status':
                'error',
                'message':
                'You registered using Facebook and we cannot reset your password.',
            })
Esempio n. 2
0
def post_user_forgotusername():
    email = request.json.get('email')
    user = User.query.filter_by(email=email).first()
    if not user:
        return jsonify({
            'status': 'error',
            'message': 'No user with that email address found',
        })
    else:
        if 'sizesquirrel' in user.provider_id:
            username = user.username
            # send email
            send_email(
                "SizeSquirrel - Your SizeSquirrel Username",
                current_app.config['ADMINS'][0], [user.email],
                render_template("emails/forgot_username.txt",
                                username=username),
                render_template("emails/forgot_username.html",
                                username=username))
            return jsonify({
                'status':
                "success",
                'message':
                'An email has been sent with your username'
            })
        else:
            return jsonify({
                'status':
                'error',
                'message':
                'You registered using Facebook please log in using Facebook.',
            })
Esempio n. 3
0
    def post(request, id):
        context = request.data
        current_course = Course.objects.get(id=id)

        persons = Subscriber.objects.filter(course__id=id,
                                            email=context['email'])
        if persons.exists():
            current_person = persons.first()
            current_person.name = context['name']
            current_person.number = context['number']
            current_person.save()
        else:
            new_person = Subscriber(name=context['name'],
                                    email=context['email'],
                                    number=context['number'],
                                    course=current_course)
            new_person.save()

        person = Subscriber.objects.filter(course__id=id,
                                           email=context['email']).first()
        if current_course.cost != 0:
            discount = 0
            if context['promocode'] != "null":
                discount = PromoCode.objects.get(
                    slug=context['promocode']).discount

            return CourseProcessing._init_bank_transaction(
                current_course, person, discount)
        send_email(person.email, current_course)
        return Response(False)
Esempio n. 4
0
    def post(request, id):
        person = Subscriber.objects.get(id=id)
        course = person.course

        if request.data['Status'] in ('REJECTED', 'REFUNDED'):
            person.status = 1
        elif request.data['Status'] == 'CONFIRMED':
            person.status = 2
            send_email(person.email, course)
        person.save()
        return Response({'Message': 'OK'})
Esempio n. 5
0
def send_admin_missing_items(feed):
    # make a list of missing items and send to admin
    missing_items = []
    missing_brands = []

    for product in feed["datafeed"]:
        if product.get('SSMatch') is None:
            # print product["Product_Name"]
            # print product["Brand_Name"]
            # print feed["retailer_name"]
            if product["Brand_Name"]:
                if product["Brand_Name"].lower() in CONSTANT_BRANDS:
                    missing_items.append({
                        'Product_Name':
                        product["Product_Name"],
                        'Brand_Name':
                        product["Brand_Name"],
                        'Retailer_Name':
                        feed["retailer_name"]
                    })
                else:
                    if product["Brand_Name"] not in missing_brands:
                        missing_brands.append(product["Brand_Name"])

    emailSubject = "Missing Items - " + feed["retailer_name"] + " - " + str(
        len(missing_items))
    if app.debug is not True and len(missing_items) > 0:
        send_email(
            emailSubject, current_app.config['ADMINS'][0],
            [current_app.config['ADMINS'][0]],
            render_template(
                "emails/admin_missing_items.txt",
                missing_items=missing_items,
                missing_brands=missing_brands,
                time=datetime.datetime.now().strftime("%m-%d-%Y %H:%M")),
            render_template(
                "emails/admin_missing_items.html",
                missing_items=missing_items,
                missing_brands=missing_brands,
                time=datetime.datetime.now().strftime("%m-%d-%Y %H:%M")))
Esempio n. 6
0
def send_admin_discount_items(feed):
    # discount items
    discount_items = []

    for product in feed["datafeed"]:
        if product.get('SSMatch') is not None:
            datafeed_product = dict(product)
            percent_off = (float(datafeed_product["Retail_Price"]) - float(
                datafeed_product["Sale_Price"])) * 100 / float(
                    datafeed_product["Retail_Price"])
            if percent_off > 30:
                if "Variants" in product and product["Variants"] is not None:

                    def isFloat(param):
                        try:
                            float(param)
                            return True
                        except:
                            return False

                    # print feed["retailer_name"]
                    # print product["Product_Name"]
                    # print product["Variants"]
                    # print len(product["Variants"])
                    product["Variants"] = [
                        w.replace(' ', '') for w in product["Variants"]
                    ]
                    product["Variants"] = [
                        w.replace('EU', '') for w in product["Variants"]
                    ]
                    product["Variants"] = [
                        w.replace('US', '') for w in product["Variants"]
                    ]
                    product["Variants"] = [
                        w.replace('/', '') for w in product["Variants"]
                    ]
                    product["Variants"] = [
                        w.replace('UK', '') for w in product["Variants"]
                    ]
                    product["Variants"] = [
                        s for s in product["Variants"] if isFloat(s)
                    ]
                    product["Variants"] = [
                        s for s in product["Variants"]
                        if 6 <= float(s) <= 12 or 38 <= float(s) <= 44
                    ]

                    if len(product["Variants"]) > 5:
                        # print product["Product_Name"]
                        # print product["Variants"]
                        # print any(
                        #     6 <= float(size) <= 12 for size in product["Variants"])
                        discount_items.append({
                            'Product_Name':
                            product["Product_Name"],
                            'Brand_Name':
                            product["Brand_Name"],
                            'Retailer_Name':
                            feed["retailer_name"],
                            'Percent_Off':
                            int(round(percent_off)),
                            'Variants':
                            product["Variants"],
                            'Sale_Price':
                            product["Sale_Price"],
                            'Buy_Link':
                            product["Buy_Link"]
                        })
    emailSubject = "Discount Items - " + feed["retailer_name"] + " - " + str(
        len(discount_items))
    if app.debug is not True and len(discount_items) > 0:
        send_email(
            emailSubject, current_app.config['ADMINS'][0],
            [current_app.config['ADMINS'][0]],
            render_template(
                "emails/admin_discount_items.txt",
                discount_items=discount_items,
                time=datetime.datetime.now().strftime("%m-%d-%Y %H:%M")),
            render_template(
                "emails/admin_discount_items.html",
                discount_items=discount_items,
                time=datetime.datetime.now().strftime("%m-%d-%Y %H:%M")))