Esempio n. 1
0
    def send_invitation(self, email, inviter_id):
        """
        Sends an email inviation to `email` from `invited_id`.
        """
        from django.core.mail import EmailMultiAlternatives
        from django.template.loader import render_to_string
        from sefaria.model import UserProfile

        inviter = UserProfile(id=inviter_id)
        curr_lang = translation.get_language()
        try:
            translation.activate(inviter.settings["interface_language"][0:2])
            message_html = render_to_string(
                "email/collection_signup_invitation_email.html", {
                    "inviter": inviter.full_name,
                    "collection_slug": self.slug,
                    "registerUrl": "/register?next=%s" % self.url
                })
        finally:
            translation.activate(curr_lang)
        subject = _("%(name)s invited you to a collection on Sefaria") % {
            'name': inviter.full_name
        }
        from_email = "Sefaria <*****@*****.**>"
        to = email

        msg = EmailMultiAlternatives(subject, message_html, from_email, [to])
        msg.content_subtype = "html"  # Main content is now text/html
        msg.send()
Esempio n. 2
0
    def send_invitation(self, email, inviter_id):
        """
        Sends an email inviation to `email` from `invited_id`.
        """
        from django.core.mail import EmailMultiAlternatives
        from django.template.loader import render_to_string
        from sefaria.model import UserProfile

        inviter       = UserProfile(id=inviter_id)
        message_html  = render_to_string("email/group_signup_invitation_email.html", 
                                        {
                                            "inviter": inviter.full_name,
                                            "groupName": self.name,
                                            "registerUrl": "/register?next=%s" % self.url
                                        })
        subject       = "%s invited you to join a group on Sefaria" % (inviter.full_name)
        from_email    = "Sefaria <*****@*****.**>"
        to            = email

        msg = EmailMultiAlternatives(subject, message_html, from_email, [to])
        msg.content_subtype = "html"  # Main content is now text/html
        msg.send()
user = users[0]
if 'SEFARIA_SUPERUSER' in os.environ and "SEFARIA_SUPERPASS" in os.environ:
    if user.email == os.environ["SEFARIA_SUPERUSER"]:
        user.username = os.environ["SEFARIA_SUPERUSER"]
        user.set_password(os.environ["SEFARIA_SUPERPASS"])
        user.save()

u = User.objects.create_user(os.environ["SEFARIA_TEST_USER"],
                             email=os.environ["SEFARIA_TEST_USER"],
                             password=os.environ["SEFARIA_TEST_PASS"])
u.first_name = "Testy"
u.last_name = "McTestUser"
u.save()

# slug only seems to be saved if you save profile twice. this is weird but seems to work consistently
p = UserProfile(id=u.id)
p.mark_interrupting_message_read('newUserWelcome')
p.settings["interface_language"] = "english"
p.slug = "testy-mctestuser"
print "Test User's name and slug"
print p.full_name
print p.slug
p.save()
p = UserProfile(id=u.id)
p.slug = "testy-mctestuser"
p.save()
p = UserProfile(id=u.id)
print "Test User's name and slug after save"
print p.full_name
print p.slug
Esempio n. 4
0
    writer = csv.writer(csv_out)
    writer.writerow(next(reader) + [
                                     "has_account", 
                                     "sheets_count", 
                                     "public_sheets_count",
                                     "sheet_views",
                                     "bio",
                                     "organization", 
                                     "position", 
                                     "jewish_education",
                                     "profile_url",
                                   ])

    for row in reader:
      email = row[8]
      profile = UserProfile(email=email)
      
      if not profile.date_joined:
        writer.writerow(row + ["false", 0, 0, "", "", "", ""])
        continue

      has_account         = "true"
      sheets_count        = db.sheets.find({"owner": profile.id}).count()
      public_sheets_count = db.sheets.find({"owner": profile.id, "status": "public"}).count()
      sheet_views         = sum([sheet["views"] for sheet in sheet_list(query={"owner": profile.id})])
      bio                 = strip_tags(profile.bio)
      organization        = profile.organization
      position            = profile.position
      jewish_education    = ". ".join(profile.jewish_education)
      profile_url         = "https://www.sefaria.org/profile/%s" % profile.slug
Esempio n. 5
0
user = users[0]
if 'SEFARIA_SUPERUSER' in os.environ and "SEFARIA_SUPERPASS" in os.environ:
    if user.email == os.environ["SEFARIA_SUPERUSER"]:
        user.username = os.environ["SEFARIA_SUPERUSER"]
        user.set_password(os.environ["SEFARIA_SUPERPASS"])
        user.save()

u = User.objects.create_user(os.environ["SEFARIA_TEST_USER"],
                             email=os.environ["SEFARIA_TEST_USER"],
                             password=os.environ["SEFARIA_TEST_PASS"])
u.first_name = "Testy"
u.last_name = "McTestUser"
u.save()

# slug only seems to be saved if you save profile twice. this is weird but seems to work consistently
p = UserProfile(id=u.id)
p.mark_interrupting_message_read('newUserWelcome')
p.slug = "testy-mctestuser"
print "Test User's name and slug"
print p.full_name
print p.slug
p.save()
p = UserProfile(id=u.id)
p.slug = "testy-mctestuser"
p.save()
p = UserProfile(id=u.id)
print "Test User's name and slug after save"
print p.full_name
print p.slug

Esempio n. 6
0
import os
import django
django.setup()
from django.contrib.auth.models import User
from sefaria.model import UserProfile

users = User.objects.all()
user = users[0]
if 'SEFARIA_SUPERUSER' in os.environ and "SEFARIA_SUPERPASS" in os.environ:
    if user.email == os.environ["SEFARIA_SUPERUSER"]:
        user.username = os.environ["SEFARIA_SUPERUSER"]
        user.set_password(os.environ["SEFARIA_SUPERPASS"])
        user.save()

u = User.objects.create_user(os.environ["SEFARIA_TEST_USER"],
                             email=os.environ["SEFARIA_TEST_USER"],
                             password=os.environ["SEFARIA_TEST_PASS"])
u.first_name = "Testy"
u.last_name = "McTestUser"
u.save()

p = UserProfile(id=u.id)
p.mark_interrupting_message_read('newUserWelcome')