def form_valid(self, form, **kwargs):
        document = self.get_document()

        self.object_id = Document.objects.collection.insert({
            "title":
            form.cleaned_data.get("title"),
            "user_id":
            self.request.user.pk,
            "entities":
            document.entities,
            "fork_of":
            document.pk,
            "date_created":
            datetime.now(),
            "is_public":
            document.is_public,
            "_keywords":
            extract_keywords(form.cleaned_data.get("title"))
        })

        Document.objects.collection.update({'_id': ObjectId(document.pk)},
                                           {"$inc": {
                                               'fork_count': 1
                                           }})

        document = Document.objects.get(_id=ObjectId(self.object_id))
        fork_done.send(sender=self, instance=document)

        return super(NewDocumentView, self).form_valid(form)
Exemple #2
0
 def form_valid(self, form, **kwargs):
     self.object_id = get_collection("documents").insert({
         "title": form.cleaned_data.get("title"),
         "user_id": self.request.user.pk,
         "date_created": datetime.now(),
         "entities": form.cleaned_data.get("entities"),
         "_keywords": extract_keywords(form.cleaned_data.get("title"))
     })
     return super(NewDocumentView, self).form_valid(form)
Exemple #3
0
 def form_valid(self, form, **kwargs):
     self.object_id = Document.objects.collection.insert({
         "title": form.cleaned_data.get("title"),
         "user_id": self.request.user.pk,
         "date_created": datetime.now(),
         "entities": form.cleaned_data.get("entities"),
         "is_public": form.cleaned_data.get("is_public"),
         "_keywords": extract_keywords(form.cleaned_data.get("title"))
     })
     document = Document.objects.get(_id=ObjectId(self.object_id))
     document_done.send(sender=self, instance=document)
     return super(NewDocumentView, self).form_valid(form)
Exemple #4
0
 def form_valid(self, form, **kwargs):
     self.object_id = get_collection("documents").insert({
         "title":
         form.cleaned_data.get("title"),
         "user_id":
         self.request.user.pk,
         "date_created":
         datetime.now(),
         "entities":
         form.cleaned_data.get("entities"),
         "_keywords":
         extract_keywords(form.cleaned_data.get("title"))
     })
     return super(NewDocumentView, self).form_valid(form)
 def form_valid(self, form, **kwargs):
     self.object_id = Document.objects.collection.insert({
         "title":
         form.cleaned_data.get("title"),
         "user_id":
         self.request.user.pk,
         "date_created":
         datetime.now(),
         "entities":
         form.cleaned_data.get("entities"),
         "is_public":
         form.cleaned_data.get("is_public"),
         "_keywords":
         extract_keywords(form.cleaned_data.get("title"))
     })
     document = Document.objects.get(_id=ObjectId(self.object_id))
     document_done.send(sender=self, instance=document)
     return super(NewDocumentView, self).form_valid(form)
    def handle(self, *args, **options):

        get_collection("documents").ensure_index([
                ("_keywords", 1),
                ("title", 1),
            ])

        for document in get_collection("documents").find():

            print document.get("_id")

            get_collection("documents").update({
                "_id": document.get("_id")
            }, {
                "$set": {
                    "_keywords": extract_keywords(document.get("title"))
                }
            })
Exemple #7
0
    def form_valid(self, form, **kwargs):
        resource = DocumentResource()
        document = self.get_document()
        self.object_id = get_collection("documents").insert({
            "title": form.cleaned_data.get("title"),
            "user_id": self.request.user.pk,
            "entities": document.entities,
            "fork_of": document.pk,
            "date_created": datetime.now(),
            "_keywords": extract_keywords(form.cleaned_data.get("title"))
        })

        # TODO: use atomic operations for incrementing!
        resource.obj_update(bundle=resource.build_bundle(data={
            "fork_count": (document.fork_count or 0) + 1
        }), pk=document.pk)

        return super(NewDocumentView, self).form_valid(form)
Exemple #8
0
    def form_valid(self, form, **kwargs):
        document = self.get_document()

        self.object_id = Document.objects.collection.insert({
            "title": form.cleaned_data.get("title"),
            "user_id": self.request.user.pk,
            "entities": document.entities,
            "fork_of": document.pk,
            "date_created": datetime.now(),
            "is_public": document.is_public,
            "_keywords": extract_keywords(form.cleaned_data.get("title"))
        })

        Document.objects.collection.update(
            {'_id': ObjectId(document.pk)},
            {"$inc": {'fork_count': 1}})

        document = Document.objects.get(_id=ObjectId(self.object_id))
        fork_done.send(sender=self, instance=document)

        return super(NewDocumentView, self).form_valid(form)
Exemple #9
0
    def form_valid(self, form, **kwargs):
        resource = DocumentResource()
        document = self.get_document()
        self.object_id = get_collection("documents").insert({
            "title":
            form.cleaned_data.get("title"),
            "user_id":
            self.request.user.pk,
            "entities":
            document.entities,
            "fork_of":
            document.pk,
            "date_created":
            datetime.now(),
            "_keywords":
            extract_keywords(form.cleaned_data.get("title"))
        })

        # TODO: use atomic operations for incrementing!
        resource.obj_update(bundle=resource.build_bundle(
            data={"fork_count": (document.fork_count or 0) + 1}),
                            pk=document.pk)

        return super(NewDocumentView, self).form_valid(form)