Пример #1
0
def email_comment_notification(actor_to_ref, actor_from_ref, comment_ref,
                               entry_ref):
    """Send an email in response to a comment being posted.
  PARAMETERS:
    actor_to_ref - actor whom this email is going to
    actor_from_ref - actor who posted the comment
    comment_ref - the comment that was posted
    entry_ref - the entry that was commented on
  RETURNS: (subject, message)
  """

    entry_url = entry_ref.url()
    entry_mobile_url = entry_ref.url(mobile=True)
    from_name = actor_from_ref.display_nick()
    my_entry = (actor_to_ref.nick == entry_ref.actor)
    entry_actor_name = util.display_nick(entry_ref.actor)
    entry_title = entry_ref.title()

    # TODO(termie) pretty 'r up
    comment_pretty = comment_ref.extra.get('content', '')

    t = loader.get_template('common/templates/email/email_comment.txt')
    c = template.Context(locals(), autoescape=False)
    message = t.render(c)
    subject = 'New comment on %s' % (entry_ref.title())
    return (subject, message)
Пример #2
0
def email_comment_notification(actor_to_ref, actor_from_ref, 
                               comment_ref, entry_ref):
    
  """Send an email in response to a comment being posted.
  PARAMETERS:
    actor_to_ref - actor whom this email is going to
    actor_from_ref - actor who posted the comment
    comment_ref - the comment that was posted
    entry_ref - the entry that was commented on
  RETURNS: (subject, message)
  """

  SITE_NAME = util.get_metadata('SITE_NAME')
  DOMAIN = settings.DOMAIN
  POST_NAME = util.get_metadata('POST_NAME')
  entry_url = entry_ref.url()
  entry_mobile_url = entry_ref.url(mobile=True)
  from_name = actor_from_ref.display_nick()
  my_entry = (actor_to_ref.nick == entry_ref.actor)
  entry_actor_name = util.display_nick(entry_ref.actor)
  entry_title = entry_ref.title()

  
  # TODO(termie) pretty 'r up
  comment_pretty = comment_ref.extra.get('content', '')

  t = loader.get_template('common/templates/email/email_comment.txt')
  c = template.Context(locals(), autoescape=False)
  message = t.render(c)
  html_template = loader.get_template('common/templates/email/email_comment.html')
  html_message = html_template.render(c)
  subject = 'New comment on %s' % (entry_ref.title())
  return (subject, message, html_message)
Пример #3
0
def openid_createuser(request):
  person = openidgae.get_current_person(request, http.HttpResponse())
  email = person.get_email()

  res = util_externals.reponse_if_exists(email)
  if res is not None:
    return res

  nick = util_externals.get_nick_from_email(email)
  
  params = {
    'nick': nick,
    'password': util.generate_password(),
    'first_name': person.get_field_value('firstname', 'none'),
    'last_name': person.get_field_value('lastname', 'none'),
    'fromopenid': True,
    'email':email,
  }
  
  actor_ref = util_externals.user_create('google', params, util.display_nick(email), email)
  
  # NOTE: does not provide a flash message
  response = util.RedirectFlash('/', 'Welcome to %s' % util.get_metadata('SITE_NAME'))
  user.set_user_cookie(response, actor_ref)
  return response
Пример #4
0
def email_comment_notification(actor_to_ref, actor_from_ref, comment_ref, entry_ref):

    """Send an email in response to a comment being posted.
  PARAMETERS:
    actor_to_ref - actor whom this email is going to
    actor_from_ref - actor who posted the comment
    comment_ref - the comment that was posted
    entry_ref - the entry that was commented on
  RETURNS: (subject, message)
  """

    entry_url = entry_ref.url()
    entry_mobile_url = entry_ref.url(mobile=True)
    from_name = actor_from_ref.display_nick()
    my_entry = actor_to_ref.nick == entry_ref.actor
    entry_actor_name = util.display_nick(entry_ref.actor)
    entry_title = entry_ref.title()

    # TODO(termie) pretty 'r up
    comment_pretty = comment_ref.extra.get("content", "")

    t = loader.get_template("common/email/email_comment.txt")
    c = template.Context(locals(), autoescape=False)
    message = t.render(c)
    subject = "New comment on %s" % (entry_ref.title())
    return (subject, message)
Пример #5
0
def entry_actor_link(value, request=None):
    """
  Returns an actor html link.

  value     an entry_actor object.
  request   a HttpRequest (optional).
  """
    return '<a href="%s">%s</a>' % (models.actor_url(
        url_nick(value), 'user', request=request), display_nick(value))
Пример #6
0
def entry_actor_link(value, request=None):
  """
  Returns an actor html link.

  value     an entry_actor object.
  request   a HttpRequest (optional).
  """
  return '<a href="%s">%s</a>' % (models.actor_url(url_nick(value),
                                                   'user',
                                                   request=request),
                                  display_nick(value))
Пример #7
0
def user_create(service, params, username="", id="", remote_url=""):
    logging.info("user_create")
    actor_ref = api.user_create(api.ROOT, **params)
    actor_ref.access_level = "delete"

    api.post(actor_ref, nick=actor_ref.nick, message="Joined %s!" % (util.get_metadata("SITE_NAME")))

    email = params.get("email", None)
    if email is not None:
        api.email_associate(api.ROOT, actor_ref.nick, email)
    else:
        key = "emailneeded_%s" % util.display_nick(actor_ref.nick)
        memcache.client.set(key, True, 360)

    key = "firsttime_%s" % util.display_nick(actor_ref.nick)
    memcache.client.set(key, True, 360)

    external_profile_ref = api.create_external_profile(actor_ref.nick, service, username, id, remote_url)

    return actor_ref
Пример #8
0
def get_nick_from_email(email):
    nick = util.display_nick(email).replace(".", "").replace("_", "")
    view = api.actor_lookup_nick(api.ROOT, nick)

    if view:
        cont = 1
        while view is not None:
            nick_next = nick + str(cont)
            cont += 1
            view = api.actor_lookup_nick(api.ROOT, nick_next)
            if view is None:
                nick = nick_next

    return nick
Пример #9
0
def not_banned_name(s, message=None):
  if util.display_nick(s) in banned_names:
    raise exception.ValidationError(u"Bạn không được phép sử dụng tên %s." % s.split("@")[0], "nick")
Пример #10
0
def not_banned_name(s, message=None):
  if util.display_nick(s) in banned_names:
    raise exception.ValidationError("Screen name %s is not allowed." % s, "nick")
Пример #11
0
def not_banned_name(s, message=None):
    if util.display_nick(s) in banned_names:
        raise exception.ValidationError("Screen name %s is not allowed." % s,
                                        "nick")