示例#1
0
    def post(self,request,*args,**kwargs):
        from common.check.community import check_private_post_exists

        form_post = PostForm(request.POST)
        list = PostsList.objects.get(pk=self.kwargs["pk"])
        community = list.community
        check_private_post_exists(community)

        if community.is_wall_close():
            raise Http404
        elif community.is_staff_post_member_can() and not request.user.is_member_of_community(community.pk):
            raise Http404
        elif request.is_ajax() and form_post.is_valid():
            check_can_get_lists(request.user, community)
            post = form_post.save(commit=False)
            if request.POST.get('text') or request.POST.getlist('attach_items'):
                from common.notify.notify import community_notify
                from common.processing.post import get_post_offer_processing
                from common.templates import render_for_platform

                lists, attach = request.POST.getlist("lists"), request.POST.getlist('attach_items')
                new_post = post.create_offer_post(
                                            creator=request.user,
                                            attach=attach,
                                            text=post.text,
                                            list=list,
                                            community=community)
                return render_for_platform(request, 'posts/post_community/post.html', {'object': new_post})
            else:
                return HttpResponseBadRequest()
        else:
            return HttpResponseBadRequest()
示例#2
0
 def post(self, request, *args, **kwargs):
     from survey.forms import SurveyForm
     self.form = SurveyForm(request.POST, request.FILES)
     if request.is_ajax() and self.form.is_valid():
         survey = self.form.save(commit=False)
         answers = request.POST.getlist("answers")
         if not answers:
             HttpResponse("not ansvers")
         new_survey = survey.create_survey(
             title=survey.title,
             image=survey.image,
             lists=request.POST.get("list"),
             creator=request.user,
             order=survey.order,
             is_anonymous=survey.is_anonymous,
             is_multiple=survey.is_multiple,
             is_no_edited=survey.is_no_edited,
             time_end=survey.time_end,
             answers=answers,
             community=None,
         )
         return render_for_platform(request, 'survey/user/preview.html',
                                    {'object': new_survey})
     else:
         return HttpResponseBadRequest("")
示例#3
0
    def post(self, request, *args, **kwargs):
        from common.templates import render_for_platform
        from users.models import User
        from chat.models import ChatUsers
        from chat.forms import ChatForm

        self.form = ChatForm(request.POST)
        if self.form.is_valid() and request.is_ajax():
            new_chat = self.form.save(commit=False)
            new_chat.creator = request.user
            new_chat = self.form.save()
            ChatUsers.create_membership(user=request.user,
                                        is_administrator=True,
                                        chat=new_chat)
            favourite_messages_count = request.user.favourite_messages_count()
            get_header_chat = new_chat.get_header_chat(request.user.pk)
            if request.POST.get('users'):
                new_chat.invite_users_in_chat(request.POST.getlist('users'),
                                              request.user)
            return render_for_platform(
                request, 'chat/chat/detail/chat.html', {
                    'chat': new_chat,
                    'get_header_chat': get_header_chat,
                    'favourite_messages_count': favourite_messages_count
                })

        from django.http import HttpResponseBadRequest
        return HttpResponseBadRequest()
示例#4
0
    def post(self, request, *args, **kwargs):
        post = Post.objects.get(pk=self.kwargs["pk"])
        form_post, attach = PostForm(
            request.POST, instance=post), request.POST.getlist('attach_items')

        if request.is_ajax() and form_post.is_valid():
            post = form_post.save(commit=False)
            if post.text or attach:
                from common.templates import render_for_platform
                new_post = post.edit_post(
                    text=post.text,
                    category=post.category,
                    list=post.list,
                    attach=attach,
                    comments_enabled=post.comments_enabled,
                    is_signature=post.is_signature,
                    votes_on=post.votes_on,
                )
                return render_for_platform(request,
                                           'posts/post_user/my_post.html',
                                           {'object': new_post})
            else:
                return HttpResponseBadRequest()
        else:
            return HttpResponseBadRequest()
示例#5
0
    def post(self, request, *args, **kwargs):
        from video.forms import VideoForm

        video = Video.objects.get(pk=request.POST.get("pk"))
        form_post = VideoForm(request.POST, request.FILES, instance=video)
        if request.is_ajax() and form_post.is_valid(
        ) and video.list.is_user_can_create_el(request.user.pk):
            _video = form_post.save(commit=False)
            if video.type == Video.UPLOAD:
                if video.community:
                    video.community.plus_videos(1)
                else:
                    video.creator.plus_videos(1)
            video.title = _video.title
            video.description = _video.description
            video.image = _video.image
            video.votes_on = _video.votes_on
            video.comments_enabled = _video.comments_enabled
            video.type = Video.PUBLISHED
            video.save()
            return render_for_platform(request,
                                       'users/video/main_list/video.html',
                                       {'object': video})
        else:
            return HttpResponseBadRequest()
示例#6
0
    def post(self, request, *args, **kwargs):
        from communities.forms import CommunityForm
        from common.templates import render_for_platform

        self.community = Community.objects.get(pk=self.kwargs["pk"])
        self.form_post = CommunityForm(request.POST, instance=self.community)

        if request.is_ajax() and self.form_post.is_valid(
        ) and request.user.is_community_manager():
            post, membersheeps = self.form_post.save(commit=False), [
                self.community.creator
            ]
            new_post = post.create_publish_community(
                manager_id=request.user.pk,
                name=post.name,
                city=post.city,
                category=post.category)
            return render_for_platform(
                request, 'communities/detail/admin_community.html', {
                    'community': community,
                    'membersheeps': membersheeps,
                    'user': request.user
                })
        else:
            from django.http import HttpResponseBadRequest
            return HttpResponseBadRequest()
示例#7
0
	def post(self,request,*args,**kwargs):
		from common.templates import render_for_platform
		from organizations.forms import OrganizationForm

		self.form = CommunityForm(request.POST)
		if self.form.is_valid() and request.is_ajax() and request.user.is_identified():
			_organization = self.form.save(commit=False)
			organization = _community.suggest_organization(
															name=_organization.name,
															image=_organization.image,
															creator=request.user,
															city=_organization.city,
															description=_organization.description,
															email_1=_organization.email_1,
															email_2=_organization.email_2,
															phone_1=_organization.phone_1,
															phone_2=_organization.phone_2,
															address_1=_organization.address_1,
															address_2=_organization.address_2,
															type=_organization.type,
															)
			return render_for_platform(request, 'organizations/detail/suggest_community.html',{'organization': organization})
		else:
			from django.http import HttpResponseBadRequest
			return HttpResponseBadRequest()
示例#8
0
    def post(self, request, *args, **kwargs):
        from organizations.forms import OrganizationForm
        from common.templates import render_for_platform

        self.form_post = OrganizationForm(request.POST)

        if request.is_ajax() and self.form_post.is_valid(
        ) and request.user.is_organization_manager():
            post = self.form_post.save(commit=False)
            new_post = post.create_manager_organization(
                name=post.name,
                description=post.description,
                elect=post.elect,
                image=post.image,
                email_1=post.email_1,
                email_2=post.email_2,
                phone_1=post.phone_1,
                phone_2=post.phone_2,
                address_1=post.address_1,
                address_2=post.address_2,
                type=post.type,
                creator=request.user)
            return render_for_platform(request, '<template>',
                                       {'organization': new_post})
        else:
            from django.http import HttpResponseBadRequest
            return HttpResponseBadRequest()
示例#9
0
    def post(self, request, *args, **kwargs):
        from common.templates import render_for_platform
        from communities.forms import CommunityForm

        self.form = CommunityForm(request.POST)
        if self.form.is_valid() and request.is_ajax():
            new_community, membersheeps = self.form.save(commit=False), [
                request.user,
            ]
            community = Community.create_community(
                name=new_community.name,
                category=new_community.category,
                type=new_community.type,
                creator=request.user)
            data = {
                'is_stat_open': True,
                'is_settings_open': True,
                'is_message_open': True,
                'is_photo_open': True,
                'is_post_open': True,
                'is_member_open': True,
                'is_doc_open': True,
                'is_video_open': True,
                'is_music_open': True,
                'is_good_open': True,
                'community': community,
                'post_list_pk': community.get_post_list().pk,
                'membersheeps': membersheeps,
            }
            return render_for_platform(
                request, 'communities/detail/public_community.html', data)
        else:
            from django.http import HttpResponseBadRequest
            return HttpResponseBadRequest()
示例#10
0
	def post(self,request,*args,**kwargs):
		from common.templates import render_for_platform
		from blog.forms import BlogCommentForm

		self.comment = BlogComment.objects.get(pk=self.kwargs["pk"])
		self.form = BlogCommentForm(request.POST,instance=self.comment)
		if request.is_ajax() and self.form.is_valid():
			_comment = self.form.save(commit=False)
			new_comment = _comment.edit_comment(text=_comment.text, attach = request.POST.getlist("attach_items"))
			if self.comment.parent:
				return render_for_platform(request, 'blog/comment/reply.html',{'reply': self.comment})
			else:
				return render_for_platform(request, 'blog/comment/parent.html',{'comment': self.comment})
		else:
			return HttpResponseBadRequest()
		return super(BlogCommentEdit,self).get(request,*args,**kwargs)
示例#11
0
    def post(self, request, *args, **kwargs):
        from communities.models import Community
        from common.templates import render_for_platform
        from article.forms import ArticleForm

        self.form, self.community = ArticleForm(
            request.POST,
            request.FILES), Community.objects.get(pk=self.kwargs["pk"])
        if self.form.is_valid() and request.user.is_staff_of_community(
                self.community.pk):
            article = self.form.save(commit=False)
            new_article = article.create_article(
                creator=request.user,
                content=article.content,
                community=self.community,
                g_image=article.g_image,
                title=article.title,
            )
            return render_for_platform(
                request, 'posts/post_community/admin_article.html', {
                    'object': new_article,
                    'user': request.user
                })
        else:
            from django.http import HttpResponseBadRequest
            HttpResponseBadRequest()
示例#12
0
文件: views.py 项目: Interesnij/rus
    def post(self, request, *args, **kwargs):
        from common.templates import render_for_platform
        from tinytag import TinyTag

        list = DocsList.objects.get(pk=self.kwargs["pk"])
        if request.is_ajax() and list.is_user_can_create_el(request.user.pk):
            docs, order, count = [], list.count, 0
            for file in request.FILES.getlist('file'):
                count += 1
                order += 1
                doc = Doc.objects.create(creator=request.user,
                                         file=file,
                                         list=list,
                                         title=file.name,
                                         order=order,
                                         community=list.community)
                docs += [
                    doc,
                ]
            list.count = order
            list.save(update_fields=["count"])
            if list.community:
                list.community.plus_docs(count)
            else:
                list.creator.plus_docs(count)
            return render_for_platform(request, 'docs/new_docs.html', {
                'object_list': docs,
                'list': list,
                'community': list.community
            })
        else:
            raise Http404
示例#13
0
    def post(self, request, *args, **kwargs):
        from chat.models import Message, Chat
        from chat.forms import MessageForm

        chat, form_post = Chat.objects.get(pk=self.kwargs["pk"]), MessageForm(
            request.POST, request.FILES)
        if request.POST.get('text') or request.POST.get(
                'attach_items') or request.POST.get(
                    'sticker') or request.POST.get('transfer'):
            message = form_post.save(commit=False)

            new_message = Message.send_message(
                chat=chat,
                creator=request.user,
                repost=None,
                text=message.text,
                sticker=request.POST.get('sticker'),
                parent=request.POST.get('parent'),
                transfer=request.POST.getlist('transfer'),
                attach=request.POST.getlist('attach_items'))
            from common.templates import render_for_platform
            return render_for_platform(request, 'chat/message/message.html',
                                       {'object': new_message})

        from django.http import HttpResponseBadRequest
        return HttpResponseBadRequest()
示例#14
0
    def post(self, request, *args, **kwargs):
        self.form = GoodForm(request.POST, request.FILES)
        self.user = User.objects.get(pk=self.kwargs["pk"])
        if request.is_ajax() and self.form.is_valid():
            from common.notify.notify import user_notify

            good = self.form.save(commit=False)
            new_good = good.create_good(
                title=good.title,
                image=good.image,
                images=request.POST.getlist('images'),
                list=good.list,
                sub_category=GoodSubCategory.objects.get(
                    pk=request.POST.get('sub_category')),
                creator=request.user,
                description=good.description,
                price=good.price,
                comments_enabled=good.comments_enabled,
                votes_on=good.votes_on,
                community=None)
            return render_for_platform(request,
                                       'goods/good_base/u_new_good.html',
                                       {'object': new_good})
        else:
            return HttpResponseBadRequest()
示例#15
0
 def post(self,request,*args,**kwargs):
     form_post= DoclistForm(request.POST)
     if request.is_ajax() and form_post.is_valid():
         list = form_post.save(commit=False)
         new_list = list.create_list(creator=request.user, name=list.name, description=list.description, order=list.order, community=None, is_public=request.POST.get("is_public"))
         return render_for_platform(request, 'user_docs/list/my_list.html',{'list': new_list, 'user_region':self.request.user.area.region})
     else:
         return HttpResponseBadRequest()
示例#16
0
    def post(self,request,*args,**kwargs):
        form_post = DocForm(request.POST, request.FILES)

        if request.is_ajax() and form_post.is_valid():
            doc = form_post.save(commit=False)
            new_doc = Doc.create_doc(creator=request.user, title=doc.title, file=doc.file, lists=request.POST.getlist("list"), is_public=request.POST.get("is_public"), community=None)
            return render_for_platform(request, 'user_docs/new_doc.html',{'doc': new_doc})
        else:
            return HttpResponseBadRequest()
示例#17
0
    def post(self,request,*args,**kwargs):
        form_post = VideoForm(request.POST, request.FILES)

        if request.is_ajax() and form_post.is_valid():
            video = form_post.save(commit=False)
            new_video = Video.create_video(creator=request.user, title=video.title, file=video.file, image=video.image, uri=video.uri, lists=request.POST.getlist("list"), is_public=request.POST.get("is_public"), community=None)
            return render_for_platform(request, 'user_video/new_video.html',{'object': new_video})
        else:
            return HttpResponseBadRequest()
示例#18
0
    def post(self,request,*args,**kwargs):
        self.doc = Doc.objects.get(pk=self.kwargs["pk"])
        form_post = DocForm(request.POST, request.FILES, instance=self.doc)

        if request.is_ajax() and form_post.is_valid():
            _doc = form_post.save(commit=False)
            new_doc = self.doc.edit_doc(title=_doc.title, file=_doc.file, lists=request.POST.getlist("list"), is_public=request.POST.get("is_public"))
            return render_for_platform(request, 'user_docs/new_doc.html',{'doc': self.doc})
        else:
            return HttpResponseBadRequest()
示例#19
0
    def post(self,request,*args,**kwargs):
        self.video = Video.objects.get(pk=self.kwargs["pk"])
        form_post = VideoForm(request.POST, request.FILES, instance=self.video)

        if request.is_ajax() and form_post.is_valid():
            _video = form_post.save(commit=False)
            new_video = self.video.edit_video(title=_video.title, image=_video.image, uri=_video.uri, file=_video.file, lists=request.POST.getlist("list"), is_public=request.POST.get("is_public"))
            return render_for_platform(request, 'user_video/new_video.html',{'object': self.video})
        else:
            return HttpResponseBadRequest()
示例#20
0
    def post(self, request, *args, **kwargs):
        from lists.models import MediaList

        if request.is_ajax():
            list, photos = MediaList.objects.get(uuid=self.kwargs["uuid"]), []
            for p in request.FILES.getlist('file'):
                photo = Photo.create_manager_photo(creator=request.user, image=p, list=list)
                photos += [photo]
            return render_for_platform(request, 'managers/manage_create/photo/new_manager_photos.html',{'object_list': photos})
        else:
            raise Http404
示例#21
0
 def post(self, request, *args, **kwargs):
     if request.is_ajax():
         list, photos = request.user.get_photo_list(), []
         for p in request.FILES.getlist('file'):
             photo = Photo.create_photo(creator=request.user,
                                        image=p,
                                        list=list)
             photos += [photo]
         return render_for_platform(request,
                                    'user_gallery/new_list_photos.html',
                                    {'object_list': photos})
     else:
         raise Http404
示例#22
0
	def post(self, request, *args, **kwargs):
		from common.templates import render_for_platform

		list = PhotoList.objects.get(pk=self.kwargs["pk"])
		if request.is_ajax() and list.is_user_can_create_el(request.user.pk):
			photos = []
			uploaded_file = request.FILES['file']
			for p in request.FILES.getlist('file'):
				photo = Photo.create_photo(creator=request.user, image=p, list=list, type="PHLIS", community=list.community)
				photos += [photo,]
			return render_for_platform(request, 'gallery/new_photos.html',{'object_list': photos, 'list': list, 'community': list.community})
		else:
			raise Http404
示例#23
0
    def get(self, request, *args, **kwargs):
        from chat.models import Message
        from django.http import Http404
        from common.templates import render_for_platform

        message = Message.objects.get(uuid=self.kwargs["uuid"])
        if request.is_ajax() and message.chat.is_user_can_fix_item(
                request.user.pk):
            info_message = message.fixed_message_for_user_chat(request.user)
            return render_for_platform(request,
                                       'chat/message/info_message.html',
                                       {'object': info_message})
        raise Http404
示例#24
0
    def post(self, request, *args, **kwargs):
        from music.forms import TrackForm
        form_post = TrackForm(request.POST, request.FILES)

        if request.is_ajax() and form_post.is_valid():
            track = form_post.save(commit=False)
            new_track = track.create_manager_track(
                creator=request.user,
                title=track.title,
                file=track.file,
                lists=request.POST.getlist("list"))
            return render_for_platform(request, 'user_music/new_track.html',
                                       {'object': new_track})
        else:
            return HttpResponseBadRequest()
示例#25
0
文件: doc.py 项目: Interesnij/deputat
    def post(self, request, *args, **kwargs):
        from docs.forms import DocForm
        form_post = DocForm(request.POST, request.FILES)

        if request.is_ajax() and form_post.is_valid():
            doc = form_post.save(commit=False)
            new_doc = doc.create_manager_doc(
                creator=request.user,
                title=doc.title,
                file=doc.file,
                lists=request.POST.getlist("list"))
            return render_for_platform(request, 'user_docs/new_doc.html',
                                       {'doc': new_doc})
        else:
            return HttpResponseBadRequest()
示例#26
0
    def post(self, request, *args, **kwargs):
        self.track = Music.objects.get(pk=self.kwargs["pk"])
        form_post = TrackForm(request.POST, request.FILES, instance=self.track)

        if request.is_ajax() and form_post.is_valid():
            _track = form_post.save(commit=False)
            new_doc = _track.edit_track(
                title=_track.title,
                file=_track.file,
                lists=request.POST.getlist("list"),
                is_public=request.POST.get("is_public"))
            return render_for_platform(request, 'user_music/new_track.html',
                                       {'object': self.track})
        else:
            return HttpResponseBadRequest()
示例#27
0
    def post(self, request, *args, **kwargs):
        form_post, list, attach = PostForm(
            request.POST), PostsList.objects.get(
                pk=self.kwargs["pk"]), request.POST.getlist('attach_items')

        if request.is_ajax() and form_post.is_valid(
        ) and list.is_user_can_create_el(request.user.pk):
            post = form_post.save(commit=False)
            creator = request.user
            if post.text or attach:
                from common.templates import render_for_platform
                new_post = post.create_post(
                    creator=creator,
                    text=post.text,
                    category=post.category,
                    list=list,
                    attach=attach,
                    parent=None,
                    comments_enabled=post.comments_enabled,
                    is_signature=post.is_signature,
                    votes_on=post.votes_on,
                    community=None)

                from common.notify.progs import user_send_notify, user_send_wall
                from notify.models import Notify, Wall

                Wall.objects.create(creator_id=creator.pk,
                                    type="POS",
                                    object_id=new_post.pk,
                                    verb="ITE")
                user_send_wall(new_post.pk, None, "create_u_post_wall")
                for user_id in creator.get_user_main_notify_ids():
                    Notify.objects.create(creator_id=creator.pk,
                                          recipient_id=user_id,
                                          type="POS",
                                          object_id=new_post.pk,
                                          verb="ITE")
                    user_send_notify(new_post.pk, creator.pk, user_id, None,
                                     "create_u_post_notify")
                creator.plus_posts(1)

                return render_for_platform(request,
                                           'posts/post_user/my_post.html',
                                           {'object': new_post})
            else:
                return HttpResponseBadRequest()
        else:
            return HttpResponseBadRequest()
示例#28
0
    def post(self, request, *args, **kwargs):
        form_post = PlaylistForm(request.POST)

        if request.is_ajax() and form_post.is_valid():
            new_list = form_post.save(commit=False)
            new_list.creator = request.user
            new_list.save()
            add_playlist(request.POST.get('permalink'), request.user, new_list)
            return render_for_platform(
                request, 'user_music/list.html', {
                    'playlist': new_list,
                    'object_list': new_list.playlist_too(),
                    'user': request.user
                })
        else:
            return HttpResponseBadRequest()
示例#29
0
    def post(self, request, *args, **kwargs):
        from chat.models import Message
        from common.templates import render_for_platform

        _message = Message.objects.get(uuid=self.kwargs["uuid"])
        if request.is_ajax():
            if request.POST.get('text') or request.POST.get('attach_items'):
                _message.edit_message(
                    text=request.POST.get('text'),
                    attach=request.POST.getlist('attach_items'))
            return render_for_platform(request,
                                       'chat/message/new_edit_message.html',
                                       {'object': _message})
        else:
            from django.http import HttpResponseBadRequest
            return HttpResponseBadRequest()
示例#30
0
    def post(self,request,*args,**kwargs):
        form_post = PostForm(request.POST)
        list = PostsList.objects.get(pk=self.kwargs["pk"])
        community = list.community
        creator = request.user
        if (community and request.user.is_administrator_of_community(community.pk)) \
            or (not community and creator.pk == list.creator.pk):
            can_create = True
        else:
            can_create = list.is_user_can_create_el(request.user.pk)

        if request.is_ajax() and form_post.is_valid() and can_create:
            post = form_post.save(commit=False)

            if request.POST.get('text') or request.POST.get('attach_items'):
                from common.templates import render_for_platform

                attach = request.POST.getlist('attach_items')
                new_post = post.create_post(
                                            creator=creator,
                                            attach=attach,
                                            text=post.text,
                                            category=post.category,
                                            list=list,
                                            parent=None,
                                            comments_enabled=post.comments_enabled,
                                            is_signature=post.is_signature,
                                            votes_on=post.votes_on,
                                            community=community,
                                        )

                from common.notify.progs import community_send_notify, community_send_wall
                from notify.models import Notify, Wall

                Wall.objects.create(creator_id=creator.pk, community_id=community.pk, type="POS", object_id=new_post.pk, verb="ITE")
                community_send_wall(new_post.pk, creator.pk, community.pk, None, "create_c_post_wall")
                for user_id in community.get_member_for_notify_ids():
                    Notify.objects.create(creator_id=creator.pk, community_id=community.pk, recipient_id=user_id, type="POS", object_id=new_post.pk, verb="ITE")
                    community_send_notify(new_post.pk, creator.pk, user_id, community.pk, None, "create_c_post_notify")
                community.plus_posts(1)
                return render_for_platform(request, 'posts/post_community/admin_post.html', {'object': new_post})
            else:
                return HttpResponseBadRequest()
        else:
            return HttpResponseBadRequest()