예제 #1
0
파일: views.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		from chat.models import Chat
		from common.templates import get_settings_template
		from asgiref.sync import async_to_sync
		from channels.layers import get_channel_layer

		self.chat = Chat.objects.get(pk=self.kwargs["pk"])
		self.pk = request.user.pk
		if self.chat.is_support():
			self.template_name = get_settings_template("chat/chat/detail/chat.html", request.user, request.META['HTTP_USER_AGENT'])
		elif self.pk in self.chat.get_members_ids():
			self.template_name = get_settings_template("chat/chat/detail/chat.html", request.user, request.META['HTTP_USER_AGENT'])
			self.chat.read_messages(self.pk)
			self.is_admin = request.user.is_administrator_of_chat(self.chat.pk)
		else:
			from django.http import Http404
			raise Http404

		self.messages = self.chat.get_messages(self.pk)
		self.favourite_messages_count = request.user.favourite_messages_count()
		self.get_header_chat = self.chat.get_header_chat(self.pk)

		channel_layer = get_channel_layer()
		payload = {
			'type': 'receive',
			'key': 'message',
			'chat_id': self.chat.pk,
			'recipient_id': str(request.user.pk),
			'name': "u_message_read",
		}
		async_to_sync(channel_layer.group_send)('notification', payload)
		return super(ChatDetailView,self).get(request,*args,**kwargs)
예제 #2
0
    def get(self, request, *args, **kwargs):
        from users.models import User
        from common.templates import get_settings_template

        if request.user.get_6_friends():
            self.template_name = get_settings_template(
                "chat/message/add_friend_message.html", request.user,
                request.META['HTTP_USER_AGENT'])
        else:
            self.template_name = get_settings_template(
                "chat/message/add_message.html", request.user,
                request.META['HTTP_USER_AGENT'])
        self.user = User.objects.get(pk=self.kwargs["pk"])
        return super(UserSendPageMessage, self).get(request, *args, **kwargs)
예제 #3
0
파일: views.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		from common.templates import get_settings_template
		from chat.models import Chat

		self.chat = Chat.objects.get(pk=self.kwargs["pk"])
		type = request.GET.get("type")
		if not type:
			type, self.list = "photo", self.chat.get_attach_photos()
		elif type == "photo":
			self.list = self.chat.get_attach_photos()
		elif type == "doc":
			self.list = self.chat.get_attach_docs()
		elif type == "music":
			self.list = self.chat.get_attach_tracks()
		elif type == "video":
			self.list = self.chat.get_attach_videos()
		elif type == "good":
			self.list = self.chat.get_attach_goods()
		elif type == "post":
			self.list = self.chat.get_attach_posts()

		if request.user.pk in self.chat.get_members_ids():
			self.template_name = get_settings_template("chat/chat/collections/" + type + ".html", request.user, request.META['HTTP_USER_AGENT'])
		else:
			from django.http import Http404
			raise Http404
		return super(ChatCollections,self).get(request,*args,**kwargs)
예제 #4
0
파일: stat.py 프로젝트: Interesnij/rus
    def get(self, request, *args, **kwargs):
        import datetime

        self.range, self.views, self.weeks, self.template_name, pk = [], [], UserNumbers.objects.dates(
            'created', 'week')[0:10], get_settings_template(
                "users/user_stat/cobertura_week.html", request.user,
                request.META['HTTP_USER_AGENT']), request.user.pk
        for i in self.weeks:
            view = request.user.get_post_views_for_week([
                i.day, i.day + 1, i.day + 2, i.day + 3, i.day + 4, i.day + 5,
                i.day + 6
            ])
            i6 = i + datetime.timedelta(days=7)
            self.range += [
                str(i.strftime('%d.%m')) + " - " + str(i6.strftime('%d.%m'))
            ]
            self.views += [view]
        dss = [
            self.weeks[0].day, self.weeks[0].day + 1, self.weeks[0].day + 2,
            self.weeks[0].day + 3, self.weeks[0].day + 4,
            self.weeks[0].day + 5, self.weeks[0].day + 6
        ]
        current_views = UserNumbers.objects.filter(
            created__day__in=dss, target=pk).values('target').distinct()
        user_ids = [use['target'] for use in current_views]
        self.users = User.objects.filter(id__in=user_ids)
        return super(UserCoberturaWeek, self).get(request, *args, **kwargs)
예제 #5
0
    def get(self, request, *args, **kwargs):
        from managers.models import SupportUsers
        from common.templates import get_settings_template
        from django.db.models import Q
        from chat.models import Chat

        if SupportUsers.objects.filter(manager=request.user.pk).exists():
            self.template_name = get_settings_template(
                "managers/support_chat.html", request.user,
                request.META['HTTP_USER_AGENT'])
            types = Q()
            manager = SupportUsers.objects.filter(
                manager=request.user.pk).first()
            if manager.level == 1:
                types.add(Q(type="SUP1"), Q.AND)
            elif manager.level == 2:
                types.add(Q(Q(type="SUP1") | Q(type="SUP2")), Q.AND)
            elif manager.level == 3:
                types.add(Q(Q(type="SUP1") | Q(type="SUP2") | Q(type="SUP3")),
                          Q.AND)
            elif manager.level == 4:
                types.add(
                    Q(
                        Q(type="SUP1") | Q(type="SUP2") | Q(type="SUP3")
                        | Q(type="SUP4")), Q.AND)
            elif manager.level == 5:
                types.add(Q(type__contains="SUP"), Q.AND)
            types.add(Q(members=1), Q.AND)
            self.chats = Chat.objects.filter(types)
        else:
            raise Http404
        return super(SupportChats, self).get(request, *args, **kwargs)
예제 #6
0
 def get(self, request, *args, **kwargs):
     self.template_name = get_settings_template(
         "video/edit_video.html", request.user,
         request.META['HTTP_USER_AGENT'])
     if request.GET.get("pk"):
         self.video = Video.objects.get(pk=request.GET.get("pk"))
     return super(VideoEdit, self).get(request, *args, **kwargs)
예제 #7
0
파일: load.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		from common.utils import get_list_of_type

		if request.GET.get('type'):
			self.list = get_list_of_type(request.GET.get('type'))
		self.template_name = get_settings_template("users/load/communities.html", request.user, request.META['HTTP_USER_AGENT'])
		return super(CommunitiesLoad,self).get(request,*args,**kwargs)
예제 #8
0
파일: load.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		from goods.models import GoodList

		self.list = request.user.get_good_list()
		self.template_name = get_settings_template("users/load/u_good_load.html", request.user, request.META['HTTP_USER_AGENT'])
		self.get_lists = GoodList.get_user_lists(request.user.pk)
		return super(UserLoadGood,self).get(request,*args,**kwargs)
예제 #9
0
    def get(self, request, *args, **kwargs):
        from common.templates import get_settings_template

        self.template_name = get_settings_template(
            "communities/manage/create_community.html", request.user,
            request.META['HTTP_USER_AGENT'])
        return super(CommunityCreate, self).get(request, *args, **kwargs)
예제 #10
0
파일: settings.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     try:
         self.private = ProfilePrivate.objects.get(user=request.user)
     except UserPrivate.DoesNotExist:
         self.private = ProfilePrivate.objects.create(user=request.user)
     self.template_name = get_settings_template(
         "users/settings/perm/private.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(UserPrivateView, self).get(request, *args, **kwargs)
예제 #11
0
파일: settings.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     try:
         self.color = UserColorSettings.objects.get(user=request.user)
     except:
         self.color = UserColorSettings.objects.create(user=request.user)
     self.template_name = get_settings_template(
         "users/settings/design.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(UserDesign, self).get(request, *args, **kwargs)
예제 #12
0
파일: load.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		self.template_name = get_settings_template("users/load/smiles_stickers.html", request.user, request.META['HTTP_USER_AGENT'])
		self.is_have_populate_smiles = request.user.is_have_populate_smiles()
		if self.is_have_populate_smiles:
			self.populate_smiles = request.user.get_populate_smiles()
		self.is_have_populate_stickers = request.user.is_have_populate_stickers()
		if self.is_have_populate_stickers:
			self.populate_stickers = request.user.get_populate_stickers()
		return super(SmilesStickersLoad,self).get(request,*args,**kwargs)
예제 #13
0
    def get(self, request, *args, **kwargs):
        from common.templates import get_settings_template
        from users.models import User

        self.user, self.template_name = User.objects.get(
            pk=self.kwargs["pk"]), get_settings_template(
                "article/u_article_add/create_article.html", request.user,
                request.META['HTTP_USER_AGENT'])
        return super(ArticleUserCreate, self).get(request, *args, **kwargs)
예제 #14
0
파일: settings.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.template_name = get_settings_template(
         "users/settings/notify.html", request.user,
         request.META['HTTP_USER_AGENT'])
     try:
         self.notify = UserNotifications.objects.get(user=request.user)
     except:
         self.notify = UserNotifications.objects.create(user=request.user)
     self.form = UserNotifyForm(instance=self.notify)
     return super(UserNotifyView, self).get(request, *args, **kwargs)
예제 #15
0
    def get(self, request, *args, **kwargs):
        from chat.models import Chat
        from common.templates import get_settings_template

        self.template_name = get_settings_template(
            "chat/chat/append_friends.html", request.user,
            request.META['HTTP_USER_AGENT'])
        if request.GET.get("chat_pk") != "null":
            self.chat = Chat.objects.get(pk=request.GET.get("chat_pk"))
        return super(InviteMembersInUserChat,
                     self).get(request, *args, **kwargs)
예제 #16
0
파일: stat.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.views, self.years, self.template_name = [], PostNumbers.objects.dates(
         'created', 'year')[0:10], get_settings_template(
             "users/user_stat/cobertura_year.html", request.user,
             request.META['HTTP_USER_AGENT'])
     for i in self.years:
         view = request.user.get_post_views_for_year(i.year)
         self.views += [view]
     #current_views = UserNumbers.objects.filter(created__year=self.years[0].year, target=pk).values('target').distinct()
     #user_ids = [use['target'] for use in current_views]
     #self.users = User.objects.filter(id__in=user_ids)
     return super(UserCoberturaYear, self).get(request, *args, **kwargs)
예제 #17
0
파일: stat.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.views, self.days, self.template_name, pk = [], UserNumbers.objects.dates(
         'created', 'day')[0:10], get_settings_template(
             "users/user_stat/cobertura_day.html", request.user,
             request.META['HTTP_USER_AGENT']), request.user.pk
     for i in self.days:
         view = request.user.get_post_views_for_day(i.day)
         self.views += [view]
     current_views = UserNumbers.objects.filter(
         created__day=self.days[0].day,
         target=pk).values('target').distinct()
     user_ids = [use['target'] for use in current_views]
     self.users = User.objects.filter(id__in=user_ids)
     return super(UserCoberturaDay, self).get(request, *args, **kwargs)
예제 #18
0
파일: load.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		self.template_name = get_settings_template("users/load/communities_post_lists.html", request.user, request.META['HTTP_USER_AGENT'])
		type = request.GET.get('type')
		if type:
			if type[:3] == "pos":
				self.lists = request.user.get_post_lists_from_staffed_comunities()
			elif type[:3] == "pho":
				self.lists = request.user.get_photo_lists_from_staffed_comunities()
			elif type[:3] == "goo":
				self.lists = request.user.get_good_lists_from_staffed_comunities()
			elif type[:3] == "vid":
				self.lists = request.user.get_video_lists_from_staffed_comunities()
			elif type[:3] == "doc":
				self.lists = request.user.get_doc_lists_from_staffed_comunities()
			elif type[:3] == "mus":
				self.lists = request.user.get_music_lists_from_staffed_comunities()
		else:
			self.lists = request.user.get_post_lists_from_staffed_comunities()
		return super(CommunitiesPostListsLoad,self).get(request,*args,**kwargs)
예제 #19
0
파일: settings.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.type = request.GET.get("action")
     if self.type == "can_see_community":
         self.users = request.user.get_can_see_community_include_users()
         self.text = "видеть сообщества"
     elif self.type == "can_see_info":
         self.users = request.user.get_can_see_info_include_users()
         self.text = "видеть информацию профиля"
     elif self.type == "can_see_friend":
         self.users = request.user.get_can_see_friend_include_users()
         self.text = "видеть друзей"
     elif self.type == "can_send_message":
         self.users = request.user.get_can_send_message_include_users()
         self.text = "писать сообщения"
     elif self.type == "can_add_in_chat":
         self.users = request.user.get_can_add_in_chat_include_users()
         self.text = "добавлять в беседы"
     elif self.type == "can_see_post":
         self.users = request.user.get_can_see_post_include_users()
         self.text = "видеть записи"
     elif self.type == "can_see_photo":
         self.users = request.user.get_can_see_photo_include_users()
         self.text = "видеть фотографии"
     elif self.type == "can_see_good":
         self.users = request.user.get_can_see_good_include_users()
         self.text = "видеть товары"
     elif self.type == "can_see_video":
         self.users = request.user.get_can_see_video_include_users()
         self.text = "видеть видеозаписи"
     elif self.type == "can_see_music":
         self.users = request.user.get_can_see_music_include_users()
         self.text = "видеть аудиозаписи"
     elif self.type == "can_see_planner":
         self.users = request.user.get_can_see_planner_include_users()
         self.text = "видеть раздел планирования"
     elif self.type == "can_see_doc":
         self.users = request.user.get_can_see_doc_include_users()
         self.text = "видеть документы"
     self.template_name = get_settings_template(
         "users/settings/perm/include_users.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(UserPrivateIncludeUsers,
                  self).get(request, *args, **kwargs)
예제 #20
0
파일: stat.py 프로젝트: Interesnij/rus
    def get(self, request, *args, **kwargs):
        self.views, self.un_views, self.years, self.template_name, pk = [], [], UserNumbers.objects.dates(
            'created', 'year')[0:10], get_settings_template(
                "users/user_stat/traffic_year.html", request.user,
                request.META['HTTP_USER_AGENT']), request.user.pk
        for i in self.years:
            view = UserNumbers.objects.filter(created__year=i.year,
                                              target=pk).count()
            self.views += [view]
        for i in self.years:
            view = UserNumbers.objects.filter(
                created__year=i.year, target=pk).distinct("target").count()
            self.un_views += [view]

        current_views = UserNumbers.objects.filter(
            created__year=self.years[0].year,
            target=pk).values('target').distinct()
        user_ids = [use['target'] for use in current_views]
        self.users = User.objects.filter(id__in=user_ids)
        return super(UserTrafficYear, self).get(request, *args, **kwargs)
예제 #21
0
파일: views.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.track = Music.objects.get(pk=self.kwargs["pk"])
     self.template_name = get_settings_template(
         "music/music_create/edit_track.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(TrackEdit, self).get(request, *args, **kwargs)
예제 #22
0
파일: settings.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.template_name = get_settings_template(
         "users/settings/remove_profile.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(UserRemoveProfile, self).get(request, *args, **kwargs)
예제 #23
0
파일: settings.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.template_name = get_settings_template(
         "users/settings/identify_send.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(UserIdentifySend, self).get(request, *args, **kwargs)
예제 #24
0
파일: settings.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.template_name = get_settings_template(
         "users/settings/edit_link.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(UserEditLink, self).get(request, *args, **kwargs)
예제 #25
0
파일: settings.py 프로젝트: Interesnij/rus
 def get(self, request, *args, **kwargs):
     self.template_name = get_settings_template(
         "users/settings/info.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(UserInfoChange, self).get(request, *args, **kwargs)
예제 #26
0
 def get(self,request,*args,**kwargs):
     self.user, self.template_name, self.all_notify = request.user, get_settings_template("notify/user_notify.html", request.user, request.META['HTTP_USER_AGENT']), request.user.get_user_notify()
     request.user.read_user_notify()
     return super(UserNotifyView,self).get(request,*args,**kwargs)
예제 #27
0
 def get(self, request, *args, **kwargs):
     self.template_name = get_settings_template(
         "follows/followings.html", request.user,
         request.META['HTTP_USER_AGENT'])
     return super(FollowingsView, self).get(request, *args, **kwargs)
예제 #28
0
파일: views.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		from common.templates import get_settings_template
		from chat.models import Chat

		self.template_name, self.chat = get_settings_template("chat/chat/fixed_list.html", request.user, request.META['HTTP_USER_AGENT']), Chat.objects.get(pk=self.kwargs["pk"])
		return super(ChatFixedMessagesView,self).get(request,*args,**kwargs)
예제 #29
0
파일: views.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		from common.templates import get_settings_template

		self.template_name, self.user = get_settings_template("chat/chat/list.html", request.user, request.META['HTTP_USER_AGENT']), request.user
		self.favourite_messages_count = self.user.favourite_messages_count()
		return super(ChatsListView,self).get(request,*args,**kwargs)
예제 #30
0
파일: views.py 프로젝트: Interesnij/rus
	def get(self,request,*args,**kwargs):
		from common.templates import get_settings_template

		self.template_name = get_settings_template("chat/chat/closed_support_list.html", request.user, request.META['HTTP_USER_AGENT'])
		return super(ClosedSupportChats,self).get(request,*args,**kwargs)