def createMessage(sender, recipient, content, date=None): convo = None convos = models.Conversation.objects.filter(user1=sender, user2=recipient) if not convos: convos = models.Conversation.objects.filter(user1=recipient, user2=sender) if not convos: convoID = helpers.createUniqueID(models.Conversation, "conversationID") convo = models.Conversation(conversationID=convoID, user1=sender, user2=recipient) convo.save() if convos: convo = convos[0] if convo: messageID = helpers.createUniqueID(models.Message, "messageID") message = models.Message(messageID=messageID, conversationID=convo.conversationID, sender=sender, recipient=recipient, content=content) message.save() if date: message.sentTime = date message.save() return message
def createProjectEvent(projectID, title, location, startDate, endDate, startTime, endTime, description, poster="mattgray", host=None, admissionInfo=None, picURL=None, eventType="Other"): postID = helpers.createUniqueID(models.EventPost, "postID") post = models.EventPost(postID=postID, projectID=projectID, poster=poster, title=title, description=description, location=location, host=host, admissionInfo=admissionInfo, startTime=startTime, endTime=endTime, startDate=startDate, endDate=endDate, eventType=eventType) post.save() if picURL and os.path.exists(picURL): picResult = urllib.urlretrieve(picURL) post.postPicture = File(open(picResult[0])) post.postPicture.name = "/event_{0}.jpg".format(postID) post.save() return postID
def createProject(poster, title, description, status, picURL, projectType="Feature Film", location="Vancouver", union="UBCP", compensation="Paid"): projectID = helpers.createUniqueID(models.ProjectPost, "postID") projectPost = models.ProjectPost(postID=projectID, projectID=projectID, poster=poster, title=title, description=description, status=status, projectType=projectType, location=location, union=union, compensation=compensation) if picURL and os.path.exists(picURL): picResult = urllib.urlretrieve(picURL) projectPost.postPicture = File(open(picResult[0])) projectPost.postPicture.name = "/project_{0}.jpg".format(projectID) projectPost.save() return projectPost
def createProjectRole(projectID, status, title, characterName, compensationType="Paid", compensationDescription="$100/day", username=None, gender=None, location=None, characterDescription=None, picURL=None, poster="mattgray", startDate=None, endDate=None): roleID = helpers.createUniqueID(models.CastingPost, "postID") rolePost = models.CastingPost( title=title, postID=roleID, projectID=projectID, poster=poster, status=status, actorName=username, characterName=characterName, gender=gender, description=characterDescription, location=location, compensationType=compensationType, compensationDescription=compensationDescription, startDate=startDate or today, endDate=endDate or tomorrow) rolePost.save() admin = models.PostAdmin(postID=roleID, username=poster) admin.save() if picURL and os.path.exists(picURL): picResult = urllib.urlretrieve(picURL) rolePost.postPicture = File(open(picResult[0])) rolePost.postPicture.name = "/casting_{0}.jpg".format(roleID) rolePost.save() return roleID
def createProjectJob(projectID, status, profession, title, compensationType="Paid", compensationDescription="$100/day", username=None, description=None, picURL=None, poster="mattgray", startDate=None, endDate=None): jobID = helpers.createUniqueID(models.WorkPost, "postID") jobPost = models.WorkPost(postID=jobID, projectID=projectID, poster=poster, workerName=username, title=title, description=description, compensationType=compensationType, compensationDescription=compensationDescription, profession=profession, status=status, startDate=startDate or today, endDate=endDate or tomorrow) jobPost.save() admin = models.PostAdmin(postID=jobID, username=poster) admin.save() if picURL and os.path.exists(picURL): picResult = urllib.urlretrieve(picURL) jobPost.postPicture = File(open(picResult[0])) jobPost.postPicture.name = "/work_{0}.jpg".format(jobID) jobPost.save() return jobID
models.Interest(username="******", mainInterest="work", subInterest="creative", professionName="Director of Photography") ] for profession in professionList: profession.save() # Add follows postFollow = models.PostFollow(postID=project1EventPostID, username="******") postFollow.save() postFollow = models.PostFollow(postID=project1ProjectID, username="******") postFollow.save() # Collaborator post collabPostID = helpers.createUniqueID(models.CollaborationPost, "postID") collabPost = models.CollaborationPost( postID=collabPostID, projectID=project1ProjectID, poster="amybolt", title="The Yosemite Project", description="I wrote a sick screenplay and am looking for a director", collaboratorRole="Director") picURL = "{0}/Agency/scripts/media/collabPost.jpg".format(basePath) if picURL and os.path.exists(picURL): picResult = urllib.urlretrieve(picURL) collabPost.postPicture = File(open(picResult[0])) collabPost.postPicture.name = "/collaboration_{0}.jpg".format(collabPostID) collabPost.save()
# User 2 project1User2 = User.objects.create_user(username="******", email="*****@*****.**", password="******", first_name="amy", last_name="bolt") project1User2.save() project1UserAccount2 = models.UserAccount(username="******", email="*****@*****.**", firstName="amy", lastName="bolt", setupComplete=True) project1UserAccount2.save() # Great Gatsby project project1ProjectID = helpers.createUniqueID(models.ProjectPost, "postID") project1ProjectPost = models.ProjectPost( postID=project1ProjectID, poster="mattgray", title="The Great Gatsby", description="Modern reimagining set in project1 York", status="In production") project1ProjectPost.save() # Nick Carraway casting post project1CastingPostID = helpers.createUniqueID(models.CastingPost, "postID") project1CastingPost = models.CastingPost(postID=project1CastingPostID, projectID=project1ProjectID, poster="mattgray", title="Nick Carraway", description="Young male lead",