def setUp(self):
        super().setUp()
        # Add artificial users to test login feature
        users = [
            User("*****@*****.**",True,"b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32",3.5,"Umut","Özdemir",False,None,None,None),
            User("*****@*****.**",False,"cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5",4.6,"Can","Deneme",True,None,None,None)
        ]
        for user in users:
            db.session.add(user)
        db.session.commit()

        jobs = [
            Jobs("Teacher"),
            Jobs("Student"),
            Jobs("Assistant")
        ]
        for job in jobs:
            db.session.add(job)
        db.session.commit()
        skills = [
            Skills("Java"),
            Skills("C"),
            Skills("Python")
        ]
        for skill in skills:
            db.session.add(skill)
        db.session.commit()
    def setUp(self):
        # Add artificial users to test login feature
        jobs = [
            Jobs("Academician"),
            Jobs("PhD Student")
        ]

        for job in jobs:
            db.session.add(job)

        db.session.commit()
        # Add artificia users to test login feature
        users = [
            User("*****@*****.**", True, "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32", 3.5,
                 "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User("*****@*****.**", False, "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5", 3.4,
                 "Can", "Deneme", False, None, None, None, 2, "boun")
        ]
        for user in users:
            db.session.add(user)
        db.session.commit()

        notifications = [
            Notification(1,"Can created a new workspace",None),
            Notification(2,"Umut deletes a workspace","/workspace/1")
        ]
        db.session.add_all(notifications)
        db.session.commit()
        related_users = [
            NotificationRelatedUser(1,2),
            NotificationRelatedUser(2,1)
        ]
        db.session.add_all(related_users)
        db.session.commit()
Esempio n. 3
0
    def setUp(self):

        jobs = [Jobs("academician"), Jobs("PhD student")]

        for job in jobs:
            db.session.add(job)

        db.session.commit()

        # Umut and Can are public users. Alperen is private user.
        users = [
            User(
                "*****@*****.**", True,
                "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32",
                3.5, "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User(
                "*****@*****.**", True,
                "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5",
                3.4, "Can", "Deneme", False, None, None, None, 2, "boun"),
            User("*****@*****.**", True, "hashedpassword", 4.6, "Alperen",
                 "Ozprivate", True, None, None, None, 1, "boun"),
            User("*****@*****.**", True, "hasheddpassword", 4.5, "Hilal",
                 "Private", True, None, None, None, 1, "boun")
        ]
        for user in users:
            db.session.add(user)

        db.session.commit()

        db.session.commit()

        collaborations = [
            Collaboration(user_1_id=1, user_2_id=2),
            Collaboration(user_1_id=2, user_2_id=1)
        ]

        for collaboration in collaborations:
            db.session.add(collaboration)
        db.session.commit()

        # Add artificial users to test follow feature.
        follows = [
            Follow(1, 2),  # Umut follows Can
            Follow(3, 2),  # Alperen follows Can
            Follow(3, 1)  # Alperen follows Umut
        ]
        for follow in follows:
            db.session.add(follow)

        reports = [Reports(1, 3, "dsds")]

        for report in reports:
            db.session.add(report)
        db.session.commit()
    def setUp(self):
        jobs = [
            Jobs("Academician"),
            Jobs("PhD Student")
        ]

        for job in jobs:
            db.session.add(job)

        db.session.commit()
        # Add artificia users to test login feature
        users = [
            User("*****@*****.**", True, "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32", 3.5,
                 "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User("*****@*****.**", False, "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5", 3.4,
                 "Can", "Deneme", False, None, None, None, 2, "boun")
        ]
        for user in users:
            db.session.add(user)
        db.session.commit()
    def setUp(self):
        # Add artificial users to test login feature
        jobs = [
            Jobs("Academician"),
            Jobs("PhD Student")
        ]

        for job in jobs:
            db.session.add(job)

        db.session.commit()
        # Add artificia users to test login feature
        users = [
            User("*****@*****.**", True, "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32", 3.5,
                 "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User("*****@*****.**", False, "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5", 3.4,
                 "Can", "Deneme", False, None, None, None, 2, "boun")
        ]
        for user in users:
            db.session.add(user)
        db.session.commit()
        research_infos = [
            ResearchInformation(1,"Multi Model Sensor Fusion","A Multi Model Sensor Fusion using Extended Kalman Filters",2020,int(ResearchType.FETCHED)),
            ResearchInformation(1,"Estimating Channel Coefficients using ANN","Using a CNN Model Estimate Channel Coefficients of a 2D Diffusion based Channel",2020,int(ResearchType.HAND_WRITTEN)),
            ResearchInformation(2,"An Academic Collaboration Platform","An Academic Collaboration Platform named Platon",2020,int(ResearchType.FETCHED))

        ]
        for research_info in research_infos:
            db.session.add(research_info)
        db.session.commit()
        follows = [
            Follow(1,2),
            Follow(2,1)
        ]
        for follow in follows:
            db.session.add(follow)
        db.session.commit()
Esempio n. 6
0
    def setUp(self):
        # Add artificial users to test login feature
        jobs = [Jobs("Academician"), Jobs("PhD Student")]

        for job in jobs:
            db.session.add(job)

        db.session.commit()
        # Add artificia users to test login feature
        users = [
            User(
                "*****@*****.**", True,
                "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32",
                3.5, "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User(
                "*****@*****.**", False,
                "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5",
                3.4, "Can", "Deneme", False, None, None, None, 2, "boun")
        ]
        for user in users:
            db.session.add(user)
        db.session.commit()

        search_history = [
            SearchHistoryItem(1, "can", 0),
            SearchHistoryItem(1, "boun", 1),
            SearchHistoryItem(1, "nanonetwork", 2),
            SearchHistoryItem(1, "umut", 0),
            SearchHistoryItem(1, "umut", 0),
            SearchHistoryItem(2, "umut", 0),
            SearchHistoryItem(2, "umut", 0),
            SearchHistoryItem(2, "computer networks", 1)
        ]

        for hist_item in search_history:
            db.session.add(hist_item)
        db.session.commit()
Esempio n. 7
0
 def post(self):
     """
         Creates a new job
     """
     form = JobsPostForm(request.form)
     if form.validate():
         new_job = Jobs(form.name.data)
         try:
             db.session.add(new_job)
             db.session.commit()
         except:
             return make_response(jsonify({'error': 'Database Connection Problem'}), 500)
         return make_response(jsonify({'msg': ' Successfully added'}), 201)
     else:
         return make_response(jsonify({'error': 'Wrong input format'}), 400)
Esempio n. 8
0
    def setUp(self):

        jobs = [Jobs("academician"), Jobs("PhD student")]

        for job in jobs:
            db.session.add(job)

        db.session.commit()

        # Umut and Can are public users. Alperen is private user.
        users = [
            User(
                "*****@*****.**", True,
                "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32",
                3.5, "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User(
                "*****@*****.**", True,
                "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5",
                3.4, "Can", "Deneme", False, None, None, None, 2, "boun"),
            User("*****@*****.**", True, "hashedpassword", 4.6, "Alperen",
                 "Ozprivate", True, None, None, None, 1, "boun"),
            User("*****@*****.**", True, "hasheddpassword", 4.5, "Hilal",
                 "Private", True, None, None, None, 1, "boun")
        ]
        for user in users:
            db.session.add(user)

        db.session.commit()

        workspaces = [
            Workspace(creator_id=1,
                      is_private=0,
                      title="coronovirus study",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # public workspace by Umut on state 1
            Workspace(creator_id=2,
                      is_private=1,
                      title="SWE difficulties",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # private workspace by Can on state 1
            Workspace(creator_id=4,
                      is_private=1,
                      title="honeybadger",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # private workspace by Hilal on state 1
            Workspace(creator_id=3,
                      is_private=0,
                      title="bos",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      )  # public workspace by Alperen on state 1
        ]

        for workspace in workspaces:
            db.session.add(workspace)

        db.session.commit()

        contributions = [
            Contribution(
                workspace_id=1, user_id=1,
                is_active=1),  # Umut will be active in coronovirus study
            Contribution(
                workspace_id=2, user_id=2,
                is_active=1),  # can will be active in SWE difficulties
            Contribution(
                workspace_id=2, user_id=3,
                is_active=1),  # alperen will be active in SWE difficulties
            Contribution(
                workspace_id=3, user_id=2,
                is_active=0),  # can will be inactive in honey badger study
            Contribution(
                workspace_id=3, user_id=4,
                is_active=1),  # hilal will be active in honey badger study
            Contribution(
                workspace_id=3, user_id=1,
                is_active=1),  # umut will be active in honey badger study
            Contribution(workspace_id=4, user_id=3,
                         is_active=1)  # alperen will be active in bos
        ]

        for contribution in contributions:
            db.session.add(contribution)
        db.session.commit()

        issues = [
            Issue(1, 1, "cure of coronovirus", "eat more sarimsak daily"),
            Issue(2, 2, "alperen's assigned issue", "denemeeee"),
            Issue(4, 3, "bravest animal is honeybadger", "really")
        ]

        for issue in issues:
            db.session.add(issue)
        db.session.commit()

        issue_assignees = [
            IssueAssignee(
                2, 3),  # alperen is assigned on issue which has issue id 2.
            IssueAssignee(1,
                          1)  # umut is assigned on issue wihch has issue id 1.
        ]

        for issue_assignee in issue_assignees:
            db.session.add(issue_assignee)
        db.session.commit()

        issue_comments = [
            IssueComment(2, 2, "makes sense"),  # Can makes comment on an issue
            IssueComment(2, 3,
                         "what is this?"),  # Alperen makes comment on an issue
            IssueComment(3, 4,
                         "hello world")  # Hilal makes comment on an issue
        ]

        for issue_comment in issue_comments:
            db.session.add(issue_comment)
        db.session.commit()
Esempio n. 9
0
    def put(requester_id, self):
        # Parses the form data.
        form = UpdateUserForm(request.form)

        # Checks whether the data is in valid form.
        # If yes, starts processing the data.
        # If not, an error is raised.
        if form.validate():
            # Tries to connect to the database.
            # If it fails, an error is raised.
            try:
                existing_user = User.query.filter_by(id=requester_id)
            except:
                return make_response(
                    jsonify({
                        "error":
                        "The server is not connected to the database."
                    }), 500)
            else:
                # Checks whether there is an existing user in the database with the given user ID.
                # If yes, starts processing the data.
                # If not, an error is raised.
                if existing_user is not None:
                    # Tries to update account information of the user.
                    # If it fails, an error is raised.
                    try:
                        # Gets the inputted parameters from the form data.
                        new_attributes = {}
                        for key, value in form.data.items():
                            if value or (value == 0):
                                new_attributes[key] = value

                        # Checks whether the form data contains "job" data.
                        if new_attributes.get("job", None):
                            # Checks whether the inputted job already exists in the database,
                            # If not, adds the job to the database.
                            # If yes, gets the ID of the job and writes it to the new user's "job_id" field.
                            job_name = new_attributes["job"].title()
                            new_user_job = Jobs.query.filter_by(
                                name=job_name).first()
                            if new_user_job is None:
                                new_user_job = Jobs(name=job_name)
                                db.session.add(new_user_job)
                                db.session.commit()
                            # Replaces the "job" in the form data with its ID.
                            new_attributes["job_id"] = new_user_job.id
                            del new_attributes["job"]
                    except:
                        return make_response(
                            jsonify({
                                "error":
                                "The server is not connected to the database."
                            }), 500)
                    # Check for File Upload
                    file_form = FileForm(request.files)
                    profile_photo_change = False
                    if file_form.validate():
                        profile_photo = file_form.profile_photo.data
                        existing_user_record = existing_user.first()
                        # Control there is a previous profile photo
                        if existing_user_record.profile_photo is not None and existing_user_record.profile_photo != '':
                            # Remove Previous Photo
                            fullpath = app.config[
                                "PROFILE_PHOTO_PATH"] + os.path.sep + existing_user_record.profile_photo
                            if os.path.isfile(fullpath):
                                os.remove(fullpath)
                        if allowed_file(profile_photo.filename):
                            profile_photo_change = True
                            filename, file_extension = os.path.splitext(
                                profile_photo.filename)
                            photo_path = str(
                                existing_user_record.id) + file_extension
                            fullpath = app.config[
                                "PROFILE_PHOTO_PATH"] + os.path.sep + photo_path
                            profile_photo.save(fullpath)
                            if existing_user_record.profile_photo != photo_path:
                                new_attributes["profile_photo"] = photo_path
                    try:
                        if new_attributes:
                            # Updates the attributes of the user in the database.
                            existing_user.update(new_attributes)
                            db.session.commit()
                        elif profile_photo_change:
                            return make_response(
                                jsonify({
                                    "message":
                                    "Profile photo successfully changed"
                                }), 201)
                        else:
                            return make_response(
                                jsonify({
                                    "message":
                                    "Server has received the request but there was no information to be updated."
                                }), 202)
                    except:
                        return make_response(
                            jsonify({
                                "error":
                                "The server is not connected to the database."
                            }), 500)

                    # Tries to update the research information of the newly updated user.
                    # If it fails, it does not raise an error.
                    # -as research information is scheduled to be fetched everyday.-
                    try:
                        ResearchInfoFetch.update_research_info(
                            existing_user.first().id)
                    except:
                        pass

                    return make_response(
                        jsonify({
                            "message":
                            "Account information has been successfully updated."
                        }), 200)
                else:
                    return make_response(
                        jsonify({"error": "The user is not found."}), 404)
        else:
            return make_response(
                jsonify({"error": "Missing data fields or invalid data."}),
                400)
Esempio n. 10
0
    def post(self):
        # Parses the form data.
        form = CreateUserForm(request.form)

        # Checks whether the data is in valid form.
        # If yes, starts processing the data.
        # If not, an error is raised.
        if form.validate():
            # Tries to connect to the database.
            # If it fails, an error is raised.
            try:
                existing_user = User.query.filter_by(
                    e_mail=form.e_mail.data).first()
            except:
                return make_response(
                    jsonify({
                        "error":
                        "The server is not connected to the database."
                    }), 500)
            else:
                # Checks whether there is an already existing user in the database with the e-mail address in the form data.
                # If not, the user gets created.
                # If yes, an error is raised.
                if existing_user is None:
                    # Tries to add the user to the database.
                    # If it fails, an error is raised.
                    try:
                        # Checks whether the inputted job already exists in the database,
                        # If not, adds the job to the database.
                        # If yes, gets the ID of the job and writes it to the new user's "job_id" field.
                        job_name = form.job.data.title()
                        new_user_job = Jobs.query.filter_by(
                            name=job_name).first()
                        if new_user_job is None:
                            new_user_job = Jobs(name=job_name)
                            db.session.add(new_user_job)
                            db.session.commit()

                        new_user = User(
                            is_valid=False,
                            e_mail=form.e_mail.data,
                            password_hashed=hashed(form.password.data),
                            name=form.name.data,
                            surname=form.surname.data,
                            is_private=False,
                            rate=-1.0,
                            profile_photo='',
                            google_scholar_name=form.google_scholar_name.data,
                            researchgate_name=form.researchgate_name.data,
                            job_id=new_user_job.id,
                            institution=form.institution.data)
                        db.session.add(new_user)
                        db.session.commit()
                    except:
                        return make_response(
                            jsonify({
                                "error":
                                "The server is not connected to the database."
                            }), 500)

                    # Tries to update the research information of the newly updated user.
                    # If it fails, it does not raise an error.
                    # -as research information is scheduled to be fetched everyday.-
                    try:
                        ResearchInfoFetch.update_research_info(new_user.id)
                    except:
                        pass

                    # Creates Initial Notification Status Record
                    try:
                        notification_status = NotificationStatus(
                            owner_id=new_user.id,
                            is_email_allowed=True,
                            is_notification_allowed=True)
                        db.session.add(notification_status)
                        db.session.commit()
                    except:
                        return make_response(
                            jsonify({
                                "error":
                                "The server is not connected to the database."
                            }), 500)

                    # Tries to send the activation mail to the user.
                    # If it fails, an error is raised.
                    try:
                        account_activation_token = generate_token(
                            new_user.id, datetime.timedelta(days=1))
                        EMailManager.send_account_activation_e_mail(
                            new_user.e_mail, account_activation_token)
                    except:
                        return make_response(
                            jsonify({
                                "error":
                                "The server could not send the account activation e-mail."
                            }), 503)
                    else:
                        return make_response(
                            jsonify({
                                "message":
                                "User has been successfully created."
                            }), 201)
                else:
                    return make_response(
                        jsonify({
                            "error":
                            "User with the given e-mail address already exists."
                        }), 409)
        else:
            return make_response(
                jsonify({"error": "Missing data fields or invalid data."}),
                400)
Esempio n. 11
0
    def setUp(self):

        super().setUp()

        jobs = [Jobs("academician"), Jobs("PhD student")]

        for job in jobs:
            db.session.add(job)

        db.session.commit()

        # Umut and Can are public users. Alperen and Hilal are private users.
        users = [
            User(
                "*****@*****.**", True,
                "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32",
                3.5, "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User(
                "*****@*****.**", True,
                "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5",
                3.4, "Can", "Bolukbas", False, None, None, None, 2, "boun"),
            User("*****@*****.**", True, "hashedpassword", 4.6, "Alperen",
                 "Ozprivate", True, None, None, None, 1, "boun"),
            User("*****@*****.**", True, "hasheddpassword", 4.5, "Hilal",
                 "Private", True, None, None, None, 1, "boun")
        ]
        for user in users:
            db.session.add(user)

        db.session.commit()

        workspaces = [
            Workspace(
                creator_id=1,
                is_private=0,
                title="coronavirus study",
                description=
                "Swiss scientists wondering if Sarimsak will cure COVID.",
                deadline=datetime.datetime(2021, 3, 3, 1, 1, 45),
                max_collaborators=5,
                state=WorkspaceState.search_for_collaborator.value
            ),  # public workspace by Umut on state 1
            Workspace(
                creator_id=2,
                is_private=0,
                title="SWE difficulties",
                description="Investigating how to make workspaces great again.",
                deadline=datetime.datetime(2021, 4, 3, 0, 1, 45),
                max_collaborators=5,
                state=WorkspaceState.search_for_collaborator.value
            ),  # public workspace by Can on state 1
            Workspace(
                creator_id=4,
                is_private=0,
                title="honeybadger",
                description="searching for bravest animal in the universe.",
                deadline=datetime.datetime(2021, 5, 3, 0, 1, 45),
                max_collaborators=5,
                state=WorkspaceState.search_for_collaborator.value
            ),  #public workspace by Hilal on state 1
            Workspace(creator_id=3,
                      is_private=1,
                      title="life",
                      description="is hard. be bravest.",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # private workspace by Alperen on state 1
        ]

        for workspace in workspaces:
            db.session.add(workspace)

        db.session.commit()

        # since we want different timestamp values of workspaces to check sorting functionality.
        extra_workspace = Workspace(
            creator_id=3,
            is_private=0,
            title="hello darkness",
            description="my old friend. be bravest.",
            deadline=datetime.datetime(2021, 12, 4, 0, 1),
            max_collaborators=2,
            state=WorkspaceState.search_for_collaborator.value
        )  # public workspace by Alperen on state 1
        db.session.add(extra_workspace)
        db.session.commit()

        skills = [
            Skills("bioinformatics"),
            Skills("C++"),
            Skills("Python"),
            Skills("bash"),
            Skills("skill")
        ]

        for skill in skills:
            db.session.add(skill)
        db.session.commit()

        workspace_skills = [
            WorkspaceSkill(workspace_id=1, skill_id=1),
            WorkspaceSkill(workspace_id=1, skill_id=2),
            WorkspaceSkill(workspace_id=1, skill_id=3),
            WorkspaceSkill(workspace_id=2, skill_id=2),
            WorkspaceSkill(workspace_id=2, skill_id=3),
            WorkspaceSkill(workspace_id=2, skill_id=4),
            WorkspaceSkill(workspace_id=5, skill_id=5)
        ]

        for workspace_skill in workspace_skills:
            db.session.add(workspace_skill)

        db.session.commit()

        contributions = [
            Contribution(
                workspace_id=1, user_id=1,
                is_active=1),  # Umut will be active in coronovirus study
            Contribution(
                workspace_id=2, user_id=2,
                is_active=1),  # can will be active in SWE difficulties
            Contribution(
                workspace_id=2, user_id=3,
                is_active=1),  # alperen will be active in SWE difficulties
            Contribution(
                workspace_id=3, user_id=2,
                is_active=0),  # can will be inactive in honey badger study
            Contribution(
                workspace_id=3, user_id=4,
                is_active=1),  # hilal will be active in honey badger study
            Contribution(
                workspace_id=3, user_id=1,
                is_active=1),  # umut will be active in honey badger study
            Contribution(workspace_id=4, user_id=3,
                         is_active=1),  # alperen will be active in life.
            Contribution(
                workspace_id=5, user_id=3,
                is_active=1),  # alperen will be active in hello darkness.
        ]

        for contribution in contributions:
            db.session.add(contribution)

        db.session.commit()
    def setUp(self):

        jobs = [Jobs("academician"), Jobs("PhD student")]

        for job in jobs:
            db.session.add(job)

        db.session.commit()

        skills = [
            Skills("Java"),
            Skills("C"),
            Skills("Python"),
            Skills("Design Patterns"),
            Skills("Deep Learning"),
            Skills("Medicine")
        ]

        for skill in skills:
            db.session.add(skill)
        db.session.commit()

        # Umut and Can are public users. Alperen is private user.
        users = [
            User(
                "*****@*****.**", True,
                "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32",
                3.5, "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User(
                "*****@*****.**", True,
                "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5",
                3.4, "Can", "Deneme", False, None, None, None, 2, "boun"),
            User("*****@*****.**", True, "hashedpassword", 4.6, "Alperen",
                 "Ozprivate", True, None, None, None, 1, "boun"),
            User("*****@*****.**", True, "hasheddpassword", 4.5, "Hilal",
                 "Private", True, None, None, None, 1, "boun")
        ]

        for user in users:
            db.session.add(user)

        db.session.commit()

        user_skills = [
            UserSkills(1, 2),
            UserSkills(1, 3),
            UserSkills(1, 5),
            UserSkills(2, 6),
            UserSkills(2, 3),
            UserSkills(2, 1),
            UserSkills(3, 4),
            UserSkills(3, 1),
            UserSkills(3, 5),
            UserSkills(4, 6),
            UserSkills(4, 3)
        ]

        for user_skill in user_skills:
            db.session.add(user_skill)

        db.session.commit()

        # Add artificial users to test follow feature.
        follows = [
            Follow(1, 2),  # Umut follows Can
            Follow(3, 2),  # Alperen follows Can
            Follow(3, 1)  # Alperen follows Umut
        ]
        for follow in follows:
            db.session.add(follow)

        db.session.commit()

        follow_requests = [
            FollowRequests(2, 3)  # Can sent follow request to Alperen.
        ]

        for follow_request in follow_requests:
            db.session.add(follow_request)

        db.session.commit()

        workspaces = [
            Workspace(creator_id=1,
                      is_private=0,
                      title="coronovirus study",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # public workspace by Umut on state 1
            Workspace(creator_id=2,
                      is_private=0,
                      title="SWE difficulties",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # private workspace by Can on state 1
            Workspace(creator_id=4,
                      is_private=1,
                      title="honeybadger",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # private workspace by Hilal on state 1
            Workspace(creator_id=3,
                      is_private=0,
                      title="bos",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      )  # public workspace by Alperen on state 1
        ]

        for workspace in workspaces:
            db.session.add(workspace)

        db.session.commit()

        workspace_skills = [
            WorkspaceSkill(workspace_id=1, skill_id=6),
            WorkspaceSkill(workspace_id=1, skill_id=5),
            WorkspaceSkill(workspace_id=1, skill_id=3),
            WorkspaceSkill(workspace_id=2, skill_id=1),
            WorkspaceSkill(workspace_id=2, skill_id=2),
            WorkspaceSkill(workspace_id=2, skill_id=3),
            WorkspaceSkill(workspace_id=2, skill_id=4),
            WorkspaceSkill(workspace_id=3, skill_id=5),
            WorkspaceSkill(workspace_id=3, skill_id=2),
            WorkspaceSkill(workspace_id=4, skill_id=1),
            WorkspaceSkill(workspace_id=4, skill_id=3)
        ]

        for workspace_skill in workspace_skills:
            db.session.add(workspace_skill)

        db.session.commit()

        contributions = [
            Contribution(
                workspace_id=1, user_id=1,
                is_active=1),  # Umut will be active in coronovirus study
            Contribution(
                workspace_id=2, user_id=2,
                is_active=1),  # can will be active in SWE difficulties
            Contribution(
                workspace_id=2, user_id=3,
                is_active=1),  # alperen will be active in SWE difficulties
            Contribution(
                workspace_id=3, user_id=2,
                is_active=0),  # can will be inactive in honey badger study
            Contribution(
                workspace_id=3, user_id=4,
                is_active=1),  # hilal will be active in honey badger study
            Contribution(workspace_id=4, user_id=3,
                         is_active=1)  # alperen will be active in bos
        ]

        for contribution in contributions:
            db.session.add(contribution)
        db.session.commit()

        # Initialize Recommendation System
        RecommendationSystem.update_all_follow_recommendations()
        RecommendationSystem.update_all_workspace_recommendations()
        RecommendationSystem.update_all_collaboration_recommendations()
Esempio n. 13
0
    def setUp(self):

        super().setUp()

        jobs = [Jobs("academician"), Jobs("PhD student")]

        for job in jobs:
            db.session.add(job)

        db.session.commit()

        # Umut and Can are public users. Alperen is private user.
        users = [
            User(
                "*****@*****.**", True,
                "b73ec5e4625ffcb6d0d70826f33be7a75d45b37046e26c4b60d9111266d70e32",
                3.5, "Umut", "Özdemir", False, None, None, None, 1, "boun"),
            User(
                "*****@*****.**", True,
                "cce0c2170d1ae52e099c716165d80119ee36840e3252e57f2b2b4d6bb111d8a5",
                3.4, "Can", "Deneme", False, None, None, None, 2, "boun"),
            User("*****@*****.**", True, "hashedpassword", 4.6, "Alperen",
                 "Ozprivate", True, None, None, None, 1, "boun"),
            User("*****@*****.**", True, "hasheddpassword", 4.5, "Hilal",
                 "Private", True, None, None, None, 1, "boun")
        ]
        for user in users:
            db.session.add(user)

        db.session.commit()

        workspaces = [
            Workspace(creator_id=1,
                      is_private=0,
                      title="coronovirus study",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # public workspace by Umut on state 1
            Workspace(creator_id=2,
                      is_private=1,
                      title="SWE difficulties",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # private workspace by Can on state 1
            Workspace(creator_id=4,
                      is_private=1,
                      title="honeybadger",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      ),  # private workspace by Hilal on state 1
            Workspace(creator_id=3,
                      is_private=0,
                      title="bos",
                      description="deneme",
                      state=WorkspaceState.search_for_collaborator.value
                      )  # public workspace by Alperen on state 1
        ]

        for workspace in workspaces:
            db.session.add(workspace)

        db.session.commit()

        contributions = [
            Contribution(
                workspace_id=1, user_id=1,
                is_active=1),  # Umut will be active in coronovirus study
            Contribution(
                workspace_id=2, user_id=2,
                is_active=1),  # can will be active in SWE difficulties
            Contribution(
                workspace_id=2, user_id=3,
                is_active=1),  # alperen will be active in SWE difficulties
            Contribution(
                workspace_id=3, user_id=2,
                is_active=0),  # can will be inactive in honey badger study
            Contribution(
                workspace_id=3, user_id=4,
                is_active=1),  # hilal will be active in honey badger study
            Contribution(
                workspace_id=3, user_id=1,
                is_active=1),  # umut will be active in honey badger study
            Contribution(workspace_id=4, user_id=3,
                         is_active=1)  # alperen will be active in bos
        ]

        for contribution in contributions:
            db.session.add(contribution)
        db.session.commit()

        milestones = [
            Milestone(1, 1, "coronovirus milestone", "eat more sarimsak daily",
                      datetime.datetime(2020, 12, 31, 23, 59, 59)),
            Milestone(2, 2, "Can's milestone", "denemeeee",
                      datetime.datetime(2020, 12, 31)),
            Milestone(4, 3, "Hilal's milestone", "really",
                      datetime.datetime(2020, 12, 31, 23, 59, 59))
        ]

        for milestone in milestones:
            db.session.add(milestone)
        db.session.commit()