Exemple #1
0
def sendInviteNotification(entity):
  """Sends out an invite notification to the user the request is for.

  Args:
    entity : A request containing the information needed to create the message
  """

  from soc.logic.models.user import logic as user_logic

  # get the user the request is for
  properties = {'link_id': entity.link_id }
  to_user = user_logic.getForFields(properties, unique=True)

  invitation_url = "http://%(host)s%(index)s" % {
      'host' : os.environ['HTTP_HOST'],
      'index': redirects.getInviteProcessRedirect(entity, None),
      }

  message_properties = {
      'role_verbose' : entity.role_verbose,
      'group': entity.scope.name,
      'invitation_url': invitation_url,
      }

  subject = DEF_INVITATION_MSG_FMT % {
      'role_verbose' : entity.role_verbose,
      'group' : entity.scope.name
      }

  template = DEF_GROUP_INVITE_NOTIFICATION_TEMPLATE

  from_user = user_logic.getForCurrentAccount()

  sendNotification(to_user, from_user, message_properties, subject, template)
def sendInviteNotification(entity):
  """Sends out an invite notification to the user the request is for.

  Args:
    entity : A request containing the information needed to create the message
  """

  from soc.logic.models.user import logic as user_logic
  from soc.views.models.role import ROLE_VIEWS

  invitation_url = 'http://%(host)s%(index)s' % {
      'host' : system.getHostname(),
      'index': redirects.getInviteProcessRedirect(entity, None),
      }

  role_params = ROLE_VIEWS[entity.role].getParams()

  message_properties = {
      'role_verbose' : role_params['name'],
      'group': entity.group.name,
      'invitation_url': invitation_url,
      }

  subject = DEF_INVITATION_MSG_FMT % {
      'role_verbose' : role_params['name'],
      'group' : entity.group.name
      }

  template = DEF_GROUP_INVITE_NOTIFICATION_TEMPLATE

  from_user = user_logic.getCurrentUser()

  sendNotification(entity.user, from_user, message_properties, subject, template)
Exemple #3
0
  def requests(self, request, access_type,
               page_name=None, params=None, **kwargs):
    """Displays the unhandled requests for this user.

    Args:
      request: the standard Django HTTP request object
      access_type : the name of the access type which should be checked
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      kwargs: not used
    """

    from soc.views.models.request import view as request_view

    req_params = request_view.getParams()

    # construct the Unhandled Invites list
    uh_params = req_params.copy()
    uh_params['public_row_extra'] = lambda entity: {
        "link": redirects.getInviteProcessRedirect(entity, None),
    }
    uh_params['list_description'] = ugettext(
        "An overview of your unhandled invites.")

    # construct the Open Requests list

    ar_params = req_params.copy()
    ar_params['public_row_action'] = {}
    ar_params['public_row_extra'] = lambda x: {}
    ar_params['list_description'] = ugettext(
        "List of your pending requests.")

    if lists.isDataRequest(request):
      return self.getRequestsListData(request, uh_params, ar_params)

    uh_list = helper.lists.getListGenerator(request, uh_params,
                                            visibility='public', idx=0)
    ar_list = helper.lists.getListGenerator(request, ar_params,
                                            visibility='public', idx=1)

    # fill contents with all the needed lists
    contents = [uh_list, ar_list]

    # call the _list method from base to display the list
    return self._list(request, req_params, contents, page_name)
Exemple #4
0
    def listSelf(self,
                 request,
                 access_type,
                 page_name=None,
                 params=None,
                 **kwargs):
        """Displays the unhandled requests for this user.

    Args:
      request: the standard Django HTTP request object
      access_type : the name of the access type which should be checked
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      kwargs: not used
    """

        # construct the Unhandled Invites list

        uh_params = params.copy()
        uh_params['public_row_extra'] = lambda entity: {
            "link": redirects.getInviteProcessRedirect(entity, None),
        }
        uh_params['list_description'] = ugettext(
            "An overview of your unhandled invites.")

        # construct the Open Requests list

        ar_params = params.copy()
        ar_params['public_row_action'] = {}
        ar_params['public_row_extra'] = lambda x: {}
        ar_params['list_description'] = ugettext(
            "List of your pending requests.")

        if request.GET.get('fmt') == 'json':
            return self.getListSelfData(request, uh_params, ar_params)

        uh_list = helper.lists.getListGenerator(request, uh_params, idx=0)
        ar_list = helper.lists.getListGenerator(request, ar_params, idx=1)

        # fill contents with all the needed lists
        contents = [uh_list, ar_list]

        # call the _list method from base to display the list
        return self._list(request, params, contents, page_name)