예제 #1
0
파일: models.py 프로젝트: gluwer/przepisymm
 def author_display(self):
   author = getattr(self, '_cached_author', None)
   
   if not author:
     author = get_cached_user(self.parent_key().name())
     if not author:
       author =  u'Nieznany/odłączony'
     self._cached_author = author
   
   return author
예제 #2
0
파일: views.py 프로젝트: gluwer/przepisymm
def user(request, id):
  user = get_cached_user(id)
  if not user:
    return NotFound()
    
  if not user.active:
    return render_to_response('gfcaccount/private.html', {'active': False})

  if (user.pro_vis == VISIBILITY[0] and request.user.key().name() != id) or (user.pro_vis == VISIBILITY[1] and not is_my_friend(request.user.key().name(), id)):
    return render_to_response('gfcaccount/private.html', {'active': True})
    
  # pobierz przepisy użytkownika
  prev, recipes, next = PagerQuery(models.Recipe) \
    .ancestor(user) \
    .filter('disabled =', False) \
    .filter('rec_vis =', VISIBILITY[2]) \
    .order('-created') \
    .fetch(settings.PAGE_SIZE, request.args.get('b', None))
  
  if request.is_xhr:
    return render_to_response('przepisy/includes/public_list.html', {
      'recipes': recipes,
      'prev': prev,
      'next': next,
      'user_id': id,
    })
  else:
    return render_to_response('gfcaccount/public.html', {
      'recipes': recipes,
      'prev': prev,
      'next': next,
      'user_id': id,
      'info': {
        'name': user.display_name,
        'public_recipes': user.rec_pub,
        'join_date': format_date(user.created, format='long', locale='pl'),
        'thumbnail': user.thumbnail_url,
      }
    })