Example #1
0
def add_request(properties, context, user, groupname=None):
  blip = context.GetBlipById(properties['blipId'])
  group = Group.get_by_key_name(Group.get_key_name(groupname))
  text = "You(%s) requested adding you to the group: %s.\n" % (user, groupname)
  if group:
    if user in group.members:
      text += "You are already a member of the group: %s." % groupname
    elif user in group.applications:
      text += ("You have already applied to join the group: %s. "
               "Please wait for a moment." % groupname)
    elif user in group.banned_addresses:
      text += "You are banned from the group: %s." % groupname
    else:
      from google.appengine.api import mail
      from google.appengine.ext import db
      body = "%s has requested joining the group: %s.\n" % (user, groupname)
      body += "You can moderate this request on following URL:\n"
      body += "http://%s.appspot.com/edit_group?key_name=%s" \
          % (get_appid(), group.key().name().replace(":", "%3A"))
      mail.send_mail(sender=settings.ADMINS[0][1],
                     to=group.owner.email,
                     subject="Join request from %s has come" % user,
                     body=body)
      def txn():
        g = Group.get(group.key())
        g.applications.append(user)
        g.put()
      db.run_in_transaction(txn)
      text += "Request to join this group has been sent!"
  else:
    text += "However, there is no such group! Sorry."
  blip.CreateChild().GetDocument().SetText(text)
Example #2
0
def desc(properties, context, user, groupname=None):
  blip = context.GetBlipById(properties['blipId'])
  group = Group.get_by_key_name(Group.get_key_name(groupname))
  text = ("You(%s) requested the description of the group: %s.\n"
          % (user, groupname))
  if group:
    root_wavelet = context.GetRootWavelet()
    text += "Group name: %s\n" % groupname
    text += "Main language: %s\n" % group.language
    text += "-------------------------------------------------\n"
    text += group.description
    text += "\n-------------------------------------------------\n"
  else:
    text += "However, there is no such group! Sorry."
  blip.CreateChild().GetDocument().SetText(text)
Example #3
0
def invite_people(properties, context, user, groupname=None):
  blip = context.GetBlipById(properties['blipId'])
  group = Group.get_by_key_name(Group.get_key_name(groupname))
  text = ("You(%s) requested inviting people of the group: %s.\n"
          % (user, groupname))
  if group:
    root_wavelet = context.GetRootWavelet()
    current_participants = root_wavelet.GetParticipants()
    for member in group.members:
      if not member in current_participants:
        root_wavelet.AddParticipant(member)
    text += "Finished inviting all the people in the group: %s" % groupname
  else:
    text += "However, there is no such group! Sorry."
  blip.CreateChild().GetDocument().SetText(text)
Example #4
0
def invite_people(properties, context, user, groupname=None):
    blip = context.GetBlipById(properties['blipId'])
    group = Group.get_by_key_name(Group.get_key_name(groupname))
    text = ("You(%s) requested inviting people of the group: %s.\n" %
            (user, groupname))
    if group:
        root_wavelet = context.GetRootWavelet()
        current_participants = root_wavelet.GetParticipants()
        for member in group.members:
            if not member in current_participants:
                root_wavelet.AddParticipant(member)
        text += "Finished inviting all the people in the group: %s" % groupname
    else:
        text += "However, there is no such group! Sorry."
    blip.CreateChild().GetDocument().SetText(text)
Example #5
0
def desc(properties, context, user, groupname=None):
    blip = context.GetBlipById(properties['blipId'])
    group = Group.get_by_key_name(Group.get_key_name(groupname))
    text = ("You(%s) requested the description of the group: %s.\n" %
            (user, groupname))
    if group:
        root_wavelet = context.GetRootWavelet()
        text += "Group name: %s\n" % groupname
        text += "Main language: %s\n" % group.language
        text += "-------------------------------------------------\n"
        text += group.description
        text += "\n-------------------------------------------------\n"
    else:
        text += "However, there is no such group! Sorry."
    blip.CreateChild().GetDocument().SetText(text)
Example #6
0
def add_request(properties, context, user, groupname=None):
    blip = context.GetBlipById(properties['blipId'])
    group = Group.get_by_key_name(Group.get_key_name(groupname))
    text = "You(%s) requested adding you to the group: %s.\n" % (user,
                                                                 groupname)
    if group:
        if user in group.members:
            text += "You are already a member of the group: %s." % groupname
        elif user in group.applications:
            text += ("You have already applied to join the group: %s. "
                     "Please wait for a moment." % groupname)
        elif user in group.banned_addresses:
            text += "You are banned from the group: %s." % groupname
        else:
            from google.appengine.api import mail
            from google.appengine.ext import db
            body = "%s has requested joining the group: %s.\n" % (user,
                                                                  groupname)
            body += "You can moderate this request on following URL:\n"
            body += "http://%s.appspot.com/edit_group?key_name=%s" \
                % (get_appid(), group.key().name().replace(":", "%3A"))
            mail.send_mail(sender=settings.ADMINS[0][1],
                           to=group.owner.email,
                           subject="Join request from %s has come" % user,
                           body=body)

            def txn():
                g = Group.get(group.key())
                g.applications.append(user)
                g.put()

            db.run_in_transaction(txn)
            text += "Request to join this group has been sent!"
    else:
        text += "However, there is no such group! Sorry."
    blip.CreateChild().GetDocument().SetText(text)
Example #7
0
def group_list(properties, context, user, **kwargs):
  lang = kwargs.get("lang", None)
  blip = context.GetBlipById(properties['blipId'])
  query = Group.all()
  text = "You(%s) requested listing groups" % user
  if lang:
    query.filter("language =", lang)
    text += " in language '%s'.\n" % lang
  else:
    text += ".\n"
  groups = query.fetch(1000)
  for group in groups:
    if lang:
      text += "%s\n" % group.name
    else:
      text += "%s (%s)\n" % (group.name, group.language)
  blip.CreateChild().GetDocument().SetText(text)
Example #8
0
def group_list(properties, context, user, **kwargs):
    lang = kwargs.get("lang", None)
    blip = context.GetBlipById(properties['blipId'])
    query = Group.all()
    text = "You(%s) requested listing groups" % user
    if lang:
        query.filter("language =", lang)
        text += " in language '%s'.\n" % lang
    else:
        text += ".\n"
    groups = query.fetch(1000)
    for group in groups:
        if lang:
            text += "%s\n" % group.name
        else:
            text += "%s (%s)\n" % (group.name, group.language)
    blip.CreateChild().GetDocument().SetText(text)
Example #9
0
 def txn():
   g = Group.get(group.key())
   g.applications.append(user)
   g.put()
Example #10
0
 def txn():
     g = Group.get(group.key())
     g.applications.append(user)
     g.put()