def get(self, request, *args, **kwargs): self.template_name = get_default_template( "quan/", "quan_home.html", request.user, request.META['HTTP_USER_AGENT']) if request.user.is_authenticated: from managers.models import SupportUsers if SupportUsers.objects.filter(manager=request.user.pk).exists(): self.i_support = True return super(QuanView, self).get(request, *args, **kwargs)
def get(self,request,*args,**kwargs): from common.templates import get_default_template self.template_name = get_default_template("users/u_list/", "all_users.html", request.user, request.META['HTTP_USER_AGENT']) all_query = ~Q(type__contains="_") if request.user.is_anonymous or request.user.is_child(): all_query.add(~Q(Q(type=User.VER_SEND)|Q(type=User.STAND)), Q.AND) self.all_users = User.objects.filter(all_query) return super(AllUsers,self).get(request,*args,**kwargs)
def get(self, request, *args, **kwargs): from users.models import User from goods.models import Good from music.models import Music from video.models import Video from communities.models import Community from posts.models import Post if request.GET.get('q'): _q = request.GET.get('q').replace("#", "%23") if "?stat" in _q: self.q = _q[:_q.find("?"):] else: self.q = _q else: self.q = "" self.sections = request.GET.get('s') if self.sections == "all" or not self.sections: _users = User.objects.filter( Q(first_name__icontains=self.q) | Q(last_name__icontains=self.q)) _communities = Community.objects.filter( Q(name__icontains=self.q) | Q(description__icontains=self.q)) _goods = Good.objects.filter( Q(title__icontains=self.q) | Q(description__icontains=self.q)) _musics = Music.objects.filter( Q(title__icontains=self.q) | Q(description__icontains=self.q)) _videos = Video.objects.filter( Q(title__icontains=self.q) | Q(description__icontains=self.q)) self.list = Post.objects.filter(text__icontains=self.q) if _users: self.users_count = _users.count() self.users = _users[:4] if _communities: self.communities_count = _communities.count() self.communities = _communities[:4] if _goods: self.goods_count = _goods.count() self.goods = _goods[:2] if _musics: self.musics_count = _musics.count() self.musics = _musics[:6] if _videos: self.videos_count = _videos.count() self.videos = _videos[:2] if self.list: self.posts_count = self.list.count() self.section = "all" elif self.sections == "people": self.list = User.objects.filter( Q(first_name__icontains=self.q) | Q(last_name__icontains=self.q)) if self.list: self.users_count = self.list.count() self.section = "people" elif self.sections == "news": self.list = Post.objects.filter(text__icontains=self.q) if self.list: self.posts_count = self.list.count() self.section = "news" elif self.sections == "communities": self.list = Community.objects.filter( Q(name__icontains=self.q) | Q(description__icontains=self.q)) if self.list: self.communities_count = self.list.count() self.section = "communities" elif self.sections == "music": self.list = Music.objects.filter( Q(title__icontains=self.q) | Q(description__icontains=self.q)) if self.list: self.musics_count = self.list.count() self.section = "music" elif self.sections == "video": self.list = Video.objects.filter( Q(title__icontains=self.q) | Q(description__icontains=self.q)) if self.list: self.videos_count = self.list.count() self.section = "video" elif self.sections == "goods": self.list = Good.objects.filter( Q(title__icontains=self.q) | Q(description__icontains=self.q)) if self.list: self.goods_count = self.list.count() self.section = "goods" self.template_name = get_default_template( "search/", "search.html", request.user, request.META['HTTP_USER_AGENT']) return super(SearchView, self).get(request, *args, **kwargs)
def get(self,request,*args,**kwargs): self.cat, self.template_name = CommunityCategory.objects.get(pk=self.kwargs["pk"]), get_default_template("communities/list/", "cat_communities.html", request.user, request.META['HTTP_USER_AGENT']) return super(CommunityCategoryView,self).get(request,*args,**kwargs)
def get(self,request,*args,**kwargs): self.template_name = get_default_template("communities/list/", "trend_communities.html", request.user, request.META['HTTP_USER_AGENT']) return super(TrendCommunities,self).get(request,*args,**kwargs)
def get(self,request,*args,**kwargs): self.c, self.template_name = Community.objects.get(pk=self.kwargs["pk"]), get_default_template("communities/detail/", "friends.html", request.user, request.META['HTTP_USER_AGENT']) return super(CommunityFriendsView,self).get(request,*args,**kwargs)
def get(self, request, *args, **kwargs): self.template_name, self.category = get_default_template( "quan/", "questions.html", request.user, request.META['HTTP_USER_AGENT']), QuestionsCategory.objects.get( name_en=self.kwargs["cat_name"]) return super(QuanCategoryView, self).get(request, *args, **kwargs)
def get(self, request, *args, **kwargs): self.template_name = get_default_template( "about/", "about.html", request.user, request.META['HTTP_USER_AGENT']) return super(AboutView, self).get(request, *args, **kwargs)