Exemplo n.º 1
0
def new_artist_to_salon(sender, receiver, password):
    salon_name = sender.first_name
    name = receiver.first_name
    to = receiver.email
    subject = SUBJECTS[15].format(salon_name=salon_name)
    html_content = render_to_string("emails/artist_welcome_from_salon.html", {'name': name, 'salon_name': salon_name, 'password': password})
    send_email(subject, html_content, to)
Exemplo n.º 2
0
def new_artist_to_salon(sender, receiver, password):
    salon_name = sender.first_name
    name = receiver.first_name
    to = receiver.email
    subject = SUBJECTS[15].format(salon_name=salon_name)
    html_content = render_to_string(
        "emails/artist_welcome_from_salon.html", {"name": name, "salon_name": salon_name, "password": password}
    )
    send_email(subject, html_content, to)
Exemplo n.º 3
0
def forgotten_password(sender, receiver):
    """Forgotten Password"""
    subject = SUBJECTS[1]
    name = receiver.first_name
    to = receiver.email
    email_token = "".join(random.choice(string.ascii_lowercase + string.digits) for x in range(32))
    token = get_object_or_None(PasswordToken, email=receiver.email)
    if token:
        token.email_token = email_token
        token.save()
    else:
        PasswordToken.objects.create(email=receiver.email, email_token=email_token)
    link = "http://glamfame.com/users/change_password/{0}".format(email_token)
    html_content = render_to_string("emails/password.html", {"receiver_name": name, "link": link})
    send_email(subject, html_content, to)
Exemplo n.º 4
0
def welcome(sender, receiver, password=None, event=None):
    """Welcome messages"""
    subject = SUBJECTS[0]
    name = receiver.first_name
    to = receiver.email
    if event == "facebook":
        html_content = render_to_string("emails/facebook_welcome.html", {"receiver_name": name, "password": password})
    else:
        emails_templates = {
            "profiles": "emails/1.html",
            "artists": "emails/artist_welcome.html",
            "salons": "emails/salon_welcome.html",
        }
        html_content = render_to_string(emails_templates[receiver.related_with], {"receiver_name": name})
    send_email(subject, html_content, to)
Exemplo n.º 5
0
def forgotten_password(sender, receiver):
    '''Forgotten Password'''
    subject = SUBJECTS[1]
    name = receiver.first_name
    to = receiver.email
    email_token = ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(32))
    token = get_object_or_None(PasswordToken, email=receiver.email)
    if token:
            token.email_token = email_token
            token.save()
    else:
            PasswordToken.objects.create(email=receiver.email, email_token=email_token)
    link = 'http://glamfame.com/users/change_password/{0}'.format(email_token)
    html_content = render_to_string('emails/password.html', {'receiver_name': name, 'link': link})
    send_email(subject, html_content, to)
Exemplo n.º 6
0
def welcome(sender, receiver, password=None, event=None):
    '''Welcome messages'''
    subject = SUBJECTS[0]
    name = receiver.first_name
    to = receiver.email
    if event == 'facebook':
        html_content = render_to_string('emails/facebook_welcome.html', {'receiver_name': name, 'password': password})
    else:
        emails_templates = {
            'profiles': 'emails/1.html',
            'artists': 'emails/artist_welcome.html',
            'salons': 'emails/salon_welcome.html',
        }
        html_content = render_to_string(emails_templates[receiver.related_with], {'receiver_name': name})
    send_email(subject, html_content, to)
Exemplo n.º 7
0
def start_following(sender, receiver):
    '''On start following'''
    data = {
        "id": 0,
        "type": "",
        "name": sender.first_name,
    }
    if sender.related_with == 'profiles':
        data["id"] = sender.profile.id
        data["type"] = "users"
    elif sender.related_with == 'artists':
        data["id"] = sender.artist.id
        data["type"] = "artists"
    else:
        data["id"] = sender.salon.id
        data["type"] = "artists"

    Notification.objects.create(
        sender=sender,
        receiver=receiver,
        short_text=NOTIFICATIONS_SHORT[6].format(**data),
        long_text=NOTIFICATIONS_LONG[6].format(**data),
    )

    '''
        After the artist have new follower
        5 - independent artist
        6 - not independant artist
    '''
    to = receiver.email
    artist = receiver.artist
    address = 'emails/5.html' if artist.salon else 'emails/6.html'
    username = sender.first_name
    subject = SUBJECTS[5].format(username=username)
    count = Followers.objects.filter(artist=artist).count()
    link = 'http://glamfame.com/artists/profile/{0}'.format(artist.id)
    artistname = receiver.first_name
    receiver_name = receiver.first_name
    html_content = render_to_string(address, {'receiver_name': receiver_name, 'username': username, 'artistname': artistname, 'count': count, 'link': link})
    send_email(subject, html_content, to)
Exemplo n.º 8
0
def start_following(sender, receiver):
    """On start following"""
    data = {"id": 0, "type": "", "name": sender.first_name}
    if sender.related_with == "profiles":
        data["id"] = sender.profile.id
        data["type"] = "users"
    elif sender.related_with == "artists":
        data["id"] = sender.artist.id
        data["type"] = "artists"
    else:
        data["id"] = sender.salon.id
        data["type"] = "artists"

    Notification.objects.create(
        sender=sender,
        receiver=receiver,
        short_text=NOTIFICATIONS_SHORT[6].format(**data),
        long_text=NOTIFICATIONS_LONG[6].format(**data),
    )

    """
        After the artist have new follower
        5 - independent artist
        6 - not independant artist
    """
    to = receiver.email
    artist = receiver.artist
    address = "emails/5.html" if artist.salon else "emails/6.html"
    username = sender.first_name
    subject = SUBJECTS[5].format(username=username)
    count = Followers.objects.filter(artist=artist).count()
    link = "http://glamfame.com/artists/profile/{0}".format(artist.id)
    artistname = receiver.first_name
    receiver_name = receiver.first_name
    html_content = render_to_string(
        address,
        {"receiver_name": receiver_name, "username": username, "artistname": artistname, "count": count, "link": link},
    )
    send_email(subject, html_content, to)