Ejemplo n.º 1
0
    def _email_now_vouched(self, vouched_by, description=''):
        """Email this user, letting them know they are now vouched."""
        name = None
        voucher_profile_link = None
        vouchee_profile_link = utils.absolutify(self.get_absolute_url())
        if vouched_by:
            name = vouched_by.full_name
            voucher_profile_link = utils.absolutify(vouched_by.get_absolute_url())

        number_of_vouches = self.vouches_received.all().count()
        template = get_template('phonebook/emails/vouch_confirmation_email.txt')
        message = template.render({
            'voucher_name': name,
            'voucher_profile_url': voucher_profile_link,
            'vouchee_profile_url': vouchee_profile_link,
            'vouch_description': description,
            'functional_areas_url': utils.absolutify(reverse('groups:index_functional_areas')),
            'groups_url': utils.absolutify(reverse('groups:index_groups')),
            'first_vouch': number_of_vouches == 1,
            'can_vouch_threshold': number_of_vouches == settings.CAN_VOUCH_THRESHOLD,
        })
        subject = _(u'You have been vouched on Mozillians.org')
        filtered_message = message.replace('"', '"').replace(''', "'")
        send_mail(subject, filtered_message, settings.FROM_NOREPLY,
                  [self.email])
Ejemplo n.º 2
0
    def _email_now_vouched(self, vouched_by, description=''):
        """Email this user, letting them know they are now vouched."""
        name = None
        voucher_profile_link = None
        vouchee_profile_link = utils.absolutify(self.get_absolute_url())
        if vouched_by:
            name = vouched_by.full_name
            voucher_profile_link = utils.absolutify(
                vouched_by.get_absolute_url())

        number_of_vouches = self.vouches_received.all().count()
        template = get_template(
            'phonebook/emails/vouch_confirmation_email.txt')
        message = template.render({
            'voucher_name':
            name,
            'voucher_profile_url':
            voucher_profile_link,
            'vouchee_profile_url':
            vouchee_profile_link,
            'vouch_description':
            description,
            'functional_areas_url':
            utils.absolutify(reverse('groups:index_functional_areas')),
            'groups_url':
            utils.absolutify(reverse('groups:index_groups')),
            'first_vouch':
            number_of_vouches == 1,
            'can_vouch_threshold':
            number_of_vouches == settings.CAN_VOUCH_THRESHOLD,
        })
        subject = _(u'You have been vouched on Mozillians.org')
        filtered_message = message.replace('"', '"').replace(''', "'")
        send_mail(subject, filtered_message, settings.FROM_NOREPLY,
                  [self.email])
Ejemplo n.º 3
0
def gravatar(email, default_avatar_url=settings.DEFAULT_AVATAR_URL,
             size=175, rating='pg'):
    """Return the Gravatar URL for an email address."""
    url = GRAVATAR_URL.format(emaildigest=md5(email).hexdigest())
    url = urlparams(url, d=utils.absolutify(default_avatar_url),
                    s=size, r=rating)
    return url
Ejemplo n.º 4
0
 def test_get_detail_mozilla_app(self):
     client = Client()
     url = reverse('api_dispatch_detail',
                   kwargs={'api_name': 'v1', 'resource_name': 'users',
                           'pk': self.user.userprofile.id})
     url = urlparams(url, app_name=self.mozilla_app.name,
                     app_key=self.mozilla_app.key)
     response = client.get(url, follow=True)
     data = json.loads(response.content)
     profile = self.user.userprofile
     eq_(response.status_code, 200)
     eq_(data['id'], profile.id)
     eq_(data['full_name'], profile.full_name)
     eq_(data['is_vouched'], profile.is_vouched)
     eq_(data['vouched_by'], profile.vouched_by.id)
     # eq_(data['date_vouched'], profile.date_vouched)
     eq_(data['groups'], list(profile.groups.values_list('name', flat=True)))
     eq_(data['skills'], list(profile.skills.values_list('name', flat=True)))
     eq_(data['accounts'],
         [{'identifier': a.identifier, 'type': a.type}
          for a in profile.externalaccount_set.all()])
     eq_(data['bio'], profile.bio)
     eq_(data['photo'], profile.photo)
     eq_(data['photo_thumbnail'], profile.get_photo_url())
     eq_(data['ircname'], profile.ircname)
     eq_(data['country'], profile.geo_country.code)
     eq_(data['region'], profile.geo_region.name)
     eq_(data['city'], profile.geo_city.name)
     eq_(data['date_mozillian'], profile.date_mozillian)
     eq_(data['timezone'], profile.timezone)
     eq_(data['email'], profile.email)
     eq_(data['url'],
         absolutify(reverse('phonebook:profile_view',
                            args=[profile.user.username])))
Ejemplo n.º 5
0
def gravatar(email,
             default_avatar_url=settings.DEFAULT_AVATAR_URL,
             size=175,
             rating='pg'):
    """Return the Gravatar URL for an email address."""
    url = GRAVATAR_URL.format(emaildigest=md5(email).hexdigest())
    url = urlparams(url,
                    d=utils.absolutify(default_avatar_url),
                    s=size,
                    r=rating)
    return url
Ejemplo n.º 6
0
    def send_thanks(self):
        """Sends email to person who friend accepted invitation."""
        template = get_template('phonebook/emails/invite_accepted.txt')
        subject = _('%s created a Mozillians profile') % self.redeemer.full_name
        profile_url = reverse('phonebook:profile_view',
                              kwargs={'username': self.redeemer.user.username})
        message = template.render({
            'inviter': self.inviter.full_name,
            'friend': self.redeemer.full_name,
            'profile': absolutify(profile_url)})
        filtered_message = message.replace('"', '"').replace(''', "'")

        send_mail(subject, filtered_message, settings.FROM_NOREPLY,
                  [self.inviter.email])
Ejemplo n.º 7
0
    def test_list_groups(self):
        user = UserFactory.create()
        group = GroupFactory.create()
        group.add_member(user.userprofile)

        client = Client()
        response = client.get(self.resource_url, follow=True)
        data = json.loads(response.content)
        eq_(data['meta']['total_count'], 1)
        eq_(data['objects'][0]['name'], group.name)
        eq_(data['objects'][0]['number_of_members'], 1)
        eq_(int(data['objects'][0]['id']), group.id)
        eq_(data['objects'][0]['url'],
            absolutify(reverse('groups:show_group', args=[group.url])))
Ejemplo n.º 8
0
    def test_list_groups(self):
        user = UserFactory.create()
        group = GroupFactory.create()
        group.add_member(user.userprofile)

        client = Client()
        response = client.get(self.resource_url, follow=True)
        data = json.loads(response.content)
        eq_(data['meta']['total_count'], 1)
        eq_(data['objects'][0]['name'], group.name)
        eq_(data['objects'][0]['number_of_members'], 1)
        eq_(int(data['objects'][0]['id']), group.id)
        eq_(data['objects'][0]['url'],
            absolutify(reverse('groups:show_group', args=[group.url])))
Ejemplo n.º 9
0
 def test_get_detail_mozilla_app(self):
     client = Client()
     url = reverse('api_dispatch_detail',
                   kwargs={
                       'api_name': 'v1',
                       'resource_name': 'users',
                       'pk': self.user.userprofile.id
                   })
     url = urlparams(url,
                     app_name=self.mozilla_app.name,
                     app_key=self.mozilla_app.key)
     response = client.get(url, follow=True)
     data = json.loads(response.content)
     profile = self.user.userprofile
     eq_(response.status_code, 200)
     eq_(data['id'], profile.id)
     eq_(data['full_name'], profile.full_name)
     eq_(data['is_vouched'], profile.is_vouched)
     eq_(data['vouched_by'], profile.vouched_by.id)
     # eq_(data['date_vouched'], profile.date_vouched)
     eq_(data['groups'], list(profile.groups.values_list('name',
                                                         flat=True)))
     eq_(data['skills'], list(profile.skills.values_list('name',
                                                         flat=True)))
     eq_(data['accounts'], [{
         'identifier': a.identifier,
         'type': a.type
     } for a in profile.externalaccount_set.all()])
     eq_(data['bio'], profile.bio)
     eq_(data['photo'], profile.photo)
     eq_(data['photo_thumbnail'], profile.get_photo_url())
     eq_(data['ircname'], profile.ircname)
     eq_(data['country'], profile.geo_country.code)
     eq_(data['region'], profile.geo_region.name)
     eq_(data['city'], profile.geo_city.name)
     eq_(data['date_mozillian'], profile.date_mozillian)
     eq_(data['timezone'], profile.timezone)
     eq_(data['email'], profile.email)
     eq_(
         data['url'],
         absolutify(
             reverse('phonebook:profile_view',
                     args=[profile.user.username])))
Ejemplo n.º 10
0
 def dehydrate_url(self, bundle):
     url = reverse('groups:show_group', args=[bundle.obj.url])
     return absolutify(url)
Ejemplo n.º 11
0
 def dehydrate_url(self, bundle):
     url = reverse('phonebook:profile_view',
                   args=[bundle.obj.user.username])
     return utils.absolutify(url)
Ejemplo n.º 12
0
def absolutify(url):
    return utils.absolutify(url)
Ejemplo n.º 13
0
 def dehydrate_url(self, bundle):
     url = reverse("groups:show_group", args=[bundle.obj.url])
     return absolutify(url)
Ejemplo n.º 14
0
 def get_url(self, absolute=True):
     """A url that can be used to redeem this invite."""
     return absolutify(
         urlparams(reverse('phonebook:register'), code=self.code))
Ejemplo n.º 15
0
 def get_absolute_url(self):
     return absolutify(reverse('groups:show_group', args=[self.url]))
Ejemplo n.º 16
0
def absolutify(url):
    return utils.absolutify(url)
Ejemplo n.º 17
0
 def get_url(self, absolute=True):
     """A url that can be used to redeem this invite."""
     return absolutify(
         urlparams(reverse('phonebook:register'), code=self.code))
Ejemplo n.º 18
0
 def get_absolute_url(self):
     cls_name = self.__class__.__name__
     url_pattern = 'groups:show_{0}'.format(cls_name.lower())
     return absolutify(reverse(url_pattern, args=[self.url]))
Ejemplo n.º 19
0
 def get_absolute_url(self):
     cls_name = self.__class__.__name__
     url_pattern = 'groups:show_{0}'.format(cls_name.lower())
     return absolutify(reverse(url_pattern, args=[self.url]))
Ejemplo n.º 20
0
 def dehydrate_url(self, bundle):
     url = reverse('phonebook:profile_view',
                   args=[bundle.obj.user.username])
     return utils.absolutify(url)