def save(self, user, story): if self.cleaned_data['id']: post = StoryLineItem.objects.get(pk=self.cleaned_data['id']) post.text = self.cleaned_data['text'] else: post = StoryLineItem(text=self.cleaned_data['text'], creator=user, story=story) post.save() if self.cleaned_data['lng'] and self.cleaned_data['lat']: location = Point(float(self.cleaned_data['lng']), float(self.cleaned_data['lat'])) pointTag = GeoPointTag(content_object=post, location=location, creator=user) pointTag.save() # add medias if self.cleaned_data["medias"]: media_uids = self.cleaned_data["medias"].split(",") for media_uid in media_uids: media = get_target_object(media_uid.strip()) storylineitem = StoryLineItemMedia(storylineitem=post, content_object=media) storylineitem.save() return post
def save(self, user, story): logging.debug("Adding Post to Experience") if self.cleaned_data['id']: post = StoryLineItem.objects.get(pk=self.cleaned_data['id']) post.text = self.cleaned_data['text'] else: post = StoryLineItem(text=self.cleaned_data['text'], creator=user, story=story) post.save() if self.cleaned_data['lng'] and self.cleaned_data['lat']: location = Point(float(self.cleaned_data['lng']), float(self.cleaned_data['lat'])) pointTag = GeoPointTag(content_object=post, location=location, creator=user) pointTag.save() # add medias if self.cleaned_data["image"]: logging.debug("Adding Post With Image") title = "IPhone - %s"%self.cleaned_data["timestamp"] image = Image(title=title) image.image.save(os.path.basename(story.title+"-"+title), ContentFile(self.cleaned_data["image"].read())) image.save() storylineAttachment = StoryLineItemMedia(storylineitem=post, content_object=image) storylineAttachment.save() logging.debug("Finished Saving Image") return post
def geotag_item(old_id, item, user): mapobject = get_mapobject_of_id(old_id) if mapobject and mapobject['location']: location = make_point_of_string(mapobject['location']) # geotagging geopointtag = GeoPointTag(content_object=item, location=location, creator=user) geopointtag.save()