Add projects to the current department

        :returns: None
        :rtype: None
        :raises: None
340974
def dep_add_prj(self, *args, **kwargs):
        
        if not self.cur_dep:
            return

        dialog = ProjectAdderDialog(department=self.cur_dep)
        dialog.exec_()
        prjs = dialog.projects
        for prj in prjs:
            prjdata = djitemdata.ProjectItemData(prj)
            treemodel.TreeItem(prjdata, self.dep_prj_model.root)
1039963
def add_flow(self, flow):
        
        from .flows import Flow
        flow = Flow.as_flow(flow)

        if flow in self.flows:
            raise self.Error("Cannot add same flow twice!")

        if not flow.allocated:
            # Set the workdir of the flow here. Create a dir in self.workdir with name flow.name
            flow_workdir = os.path.join(self.workdir, os.path.basename(flow.name))
            if flow_workdir in (flow.workdir for flow in self.flows):
                raise self.Error("Two flows have the same name and hence the same workdir!")
            flow.allocate(workdir=flow_workdir)

        # Check if we are already using a scheduler to run this flow
        flow.check_pid_file()
        flow.set_spectator_mode(False)

        flow.check_status(show=False)

        #if flow.all_ok:
        #    print("flow.all_ok: Ignoring %s" % flow)
        #    return 0

        self.flows.append(flow)
        #print("Flow %s added to the BatchLauncher" % flow)

        return 1
1217705
def add_dependency(self, p_from_todo, p_to_todo):
        
        def find_next_id():
            """
            Find a new unused ID.
            Unused means that no task has it as an 'id' value or as a 'p'
            value.
            """
            def id_exists(p_id):
                """
                Returns True if there exists a todo with the given parent ID.
                """
                for todo in self._todos:
                    number = str(p_id)
                    if todo.has_tag('id', number) or todo.has_tag('p', number):
                        return True

                return False

            new_id = 1
            while id_exists(new_id):
                new_id += 1

            return str(new_id)

        def append_projects_to_subtodo():
            """
            Appends projects in the parent todo item that are not present in
            the sub todo item.
            """
            if config().append_parent_projects():
                for project in p_from_todo.projects() - p_to_todo.projects():
                    self.append(p_to_todo, "+{}".format(project))

        def append_contexts_to_subtodo():
            """
            Appends contexts in the parent todo item that are not present in
            the sub todo item.
            """
            if config().append_parent_contexts():
                for context in p_from_todo.contexts() - p_to_todo.contexts():
                    self.append(p_to_todo, "@{}".format(context))

        if p_from_todo != p_to_todo and not self._depgraph.has_edge(
                hash(p_from_todo), hash(p_to_todo)):

            dep_id = None
            if p_from_todo.has_tag('id'):
                dep_id = p_from_todo.tag_value('id')
            else:
                dep_id = find_next_id()
                p_from_todo.set_tag('id', dep_id)

            p_to_todo.add_tag('p', dep_id)
            self._add_edge(p_from_todo, p_to_todo, dep_id)
            append_projects_to_subtodo()
            append_contexts_to_subtodo()
            self.dirty = True
74395
def edit_project(self, id_, **kwargs):
        
        data = self._wrap_dict("project", kwargs)
        return self.patch("/projects/{}.json".format(id_), data=data)
118259
def create_new_project(self):
        """"""
        self.switch_to_plugin()
        active_project = self.current_active_project
        dlg = ProjectDialog(self)
        dlg.sig_project_creation_requested.connect(self._create_project)
        dlg.sig_project_creation_requested.connect(self.sig_project_created)
        if dlg.exec_():
            if (active_project is None
                    and self.get_option('visible_if_project_open')):
                self.show_explorer()
            self.sig_pythonpath_changed.emit()
            self.restart_consoles()
312606
def add(self, dn: str, mod_list: dict) -> None:
        

        _debug("add", self, dn, mod_list)

        # if rollback of add required, delete it
        def on_commit(obj):
            obj.add(dn, None, mod_list)

        def on_rollback(obj):
            obj.delete(dn)

        # process this action
        return self._process(on_commit, on_rollback)
1111237
def move(self, folder, **kwargs):
        '''
        

        '''

        if self._proj is None:
            raise DXError("Move called when a project ID was not associated with this object handler")

        dxpy.api.project_move(self._proj, {"objects": [self._dxid],
                                           "destination": folder},
                              **kwargs)
385348
def _create_project(self, path):
        """"""
        self.open_project(path=path)
        self.setup_menu_actions()
        self.add_to_recent(path)
757708
def add(self, submission, archive, _):
        
        self.queue.put((submission, submission["result"], submission["grade"], submission["problems"], submission["tests"], submission["custom"], archive))
522768
def addProject(gh_link):
    '''  '''
    name = os.path.basename(gh_link)
    zipurl = gh_link+"/archive/master.zip"
    outzip = os.path.join('temp_data',name+'.zip')
    if not os.path.exists('temp_data'):
        os.makedirs('temp_data')
    downloadFile(zipurl,outzip)
    zip = zipfile.ZipFile(outzip,mode='r')
    outpath = os.path.join('temp_data',name)
    zip.extractall(outpath)
    zip.close()
    os.remove(outzip)
    return name,outpath
827946
def project_add_tags(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addTags' % object_id, input_params, always_retry=always_retry, **kwargs)
332487
def add_project(self, path):
        

        if not foundations.common.path_exists(path):
            return False

        path = os.path.normpath(path)
        if self.__model.get_project_nodes(path):
            self.__engine.notifications_manager.warnify(
                "{0} | '{1}' project is already opened!".format(self.__class__.__name__, path))
            return False

        LOGGER.info("{0} | Adding '{1}' project!".format(self.__class__.__name__, path))
        project_node = self.__model.register_project(path)
        if not project_node:
            return False

        self.__model.set_project_nodes(project_node)
        return True
1172298
def addprojectmember(self, project_id, user_id, access_level):
        
        # if isinstance(access_level, basestring):
        if access_level.lower() == 'master':
            access_level = 40
        elif access_level.lower() == 'developer':
            access_level = 30
        elif access_level.lower() == 'reporter':
            access_level = 20
        else:
            access_level = 10

        data = {'id': project_id, 'user_id': user_id, 'access_level': access_level}

        request = requests.post(
            '{0}/{1}/members'.format(self.projects_url, project_id),
            headers=self.headers, data=data, verify=self.verify_ssl, auth=self.auth, timeout=self.timeout)

        if request.status_code == 201:
            return True
        else:
            return False
871180
def add(self, *tasks):
        
        nodes = [x.node for x in tasks]
        self.node.add(*nodes)
        return self
405219
def user_add_prj(self, *args, **kwargs):
        
        if not self.cur_user:
            return

        dialog = ProjectAdderDialog(user=self.cur_user)
        dialog.exec_()
        prjs = dialog.projects
        for prj in prjs:
            prjdata = djitemdata.ProjectItemData(prj)
            treemodel.TreeItem(prjdata, self.user_prj_model.root)
994381
def add_project(project,**kwargs):
    
    user_id = kwargs.get('user_id')

    existing_proj = get_project_by_name(project.name,user_id=user_id)

    if len(existing_proj) > 0:
        raise HydraError("A Project with the name \"%s\" already exists"%(project.name,))

    #check_perm(user_id, 'add_project')
    proj_i = Project()
    proj_i.name = project.name
    proj_i.description = project.description
    proj_i.created_by = user_id

    attr_map = hdb.add_resource_attributes(proj_i, project.attributes)
    db.DBSession.flush() #Needed to get the resource attr's ID
    proj_data = _add_project_attribute_data(proj_i, attr_map, project.attribute_data)
    proj_i.attribute_data = proj_data

    proj_i.set_owner(user_id)

    db.DBSession.add(proj_i)
    db.DBSession.flush()

    return proj_i
856517
def create(self, project, subject, **attrs):
        
        attrs.update({'project': project, 'subject': subject})
        return self._new_resource(payload=attrs)