Esempio n. 1
0
 def get_absolute_url(self):
     view_name = 'elephantblog_category_list'
     entry_dict = {
                   'category': self.translation.slug,
                   }
     try:
         return reverse(view_name, args=(), kwargs=entry_dict)
     except NoReverseMatch:
         return reverse('elephantblog.urls/%s' % view_name, args=(), kwargs=entry_dict)
Esempio n. 2
0
 def get_absolute_url(self):
     view_name = 'elephantblog.views.entry'
     entry_dict = {'year': "%04d" %self.published_on.year,
                   'month': "%02d" %self.published_on.month,
                   'day': "%02d" %self.published_on.day,
                   'slug': self.slug}
     try:
         return reverse(view_name, args=(), kwargs=entry_dict)
     except NoReverseMatch:
         return reverse('elephantblog.urls/%s' % view_name, args=() , kwargs=entry_dict)
Esempio n. 3
0
 def children(self, page, **kwargs):
     for entry in Entry.objects.all():
         yield PagePretender(
             title=entry.title,
             url=reverse('testapp.blog_urls/blog_entry_detail',
                         kwargs={'object_id': entry.id}),
         )
Esempio n. 4
0
def get_redirect_url(url):
    """
    Tries to reverse url. If it doesn't work return the url itself.
    """
    try:
        return reverse(url)
    except:
        return url
Esempio n. 5
0
 def children(self, page, **kwargs):
     for entry in Entry.objects.all():
         yield PagePretender(
             title=entry.title,
             url=reverse(
                 'testapp.blog_urls/blog_entry_detail',
                 kwargs={'object_id': entry.id}
             ),
         )
 def children(self, page, **kwargs):
     for entry in Entry.objects.all():
         yield PagePretender(
             title=entry.title,
             url=reverse('blog_urls/blog_entry_details', kwargs={'object_id': entry.id}),
             level=kwargs['level'], 
             # NOTE: this is hack, just to make tree_info happy
             tree_id=0, lft=0, rght=0
             )
Esempio n. 7
0
def newsletter(request):

    def subscribe(registration):
        logger.debug('registration: %s' %registration)
        subscriber, created = Subscription.objects.get_or_create(email=registration['email'])
        subscriber.salutation = 'f' if registration['gender'] == 'female' else 'm'
        subscriber.first_name, subscriber.last_name = registration['first_name'], registration['last_name']
        subscriber.city = registration['location']['name']
        subscriber.language = short_language_code()
        subscriber.ip = request.META['REMOTE_ADDR']
        subscriber.activation_code = registration['facebook_id']
        subscriber.email = registration['email']
        subscriber.active = True
        subscriber.save()
        if getattr(settings, 'CLEVERREACH_GROUPS', False):
            """ Copy cleverreach.py to your project folder to make adjustments. """
            try: 
                cleverreach = __import__('%s.cleverreach' %settings.APP_MODULE)
                from cleverreach import insert_new_user, deactivate_user
            except ImportError:
                from feinheit.cleverreach import insert_new_user, deactivate_user  # TODO: Check this. Doesn't work on server.
            forms = getattr(settings, 'CLEVERREACH_FORMS', None)
            form_id = forms[short_language_code()] if forms else None    
            groups = getattr(settings, 'CLEVERREACH_GROUPS')
            group_id = groups['nl_%s' %short_language_code()]
            logger.info('sending: %s' %registration)
            status = insert_new_user(registration, group_id, activated=True, sendmail=False, form_id=form_id)
            logger.debug('Cleverreach response: %s' %status)
    
    if request.method == 'POST' and request.POST.get('signed_request', None):
        signed_request = parseSignedRequest(request.POST.get('signed_request'))
        logger.debug('newsletter signed_request: %s' %signed_request)
        signed_request['registration'].update({'facebook_id': signed_request['user_id']})
        subscribe(signed_request['registration'])
        return redirect('newsletter_thanks')
        
    site = Site.objects.all()[0].domain
    context = {'app_id': settings.FACEBOOK_APP_ID,
               'redirect_uri': 'http://%s%s' %(site, reverse('newsletter_registration'))}
    return render_to_response('content/facebook/register.txt', context, 
                              RequestContext(request))
Esempio n. 8
0
 def get_absolute_url_slideshow(self):
     return reverse('articles.views.article_details', 'articles.urls', (), {
          'slideshow_url': settings.GLOBAL_VARS['ARTICLES_URL'],
          'slug': self.slug,
     })
Esempio n. 9
0
 def get_absolute_url(self):
     return reverse('articles.views.article_details', 'articles.urls', (), {
         'pk': self.pk,
     })
Esempio n. 10
0
    def get_absolute_url_latest(self):
        return reverse('news.views.new_details', 'news.urls', (), {
             'latest_url': settings.GLOBAL_VARS['NEWS_URL'],
	     'pk': self.pk,
        })
Esempio n. 11
0
 def get_absolute_url(self):
     return reverse('news.views.new_details', 'news.urls', (), {
         'pk': self.pk,
     })