Esempio n. 1
0
def curr_proj_post(id):
    proj = get_proj(id)

    description = request.form.get('task_description')
    state = 'Assigned'
    priority = request.form.get('priority')
    assigned_to = request.form.get('assigned_to')
    in_project_id = id

    if not description or not priority or not assigned_to:
        flash('Task form failed. Please fill in everything')
        return redirect(url_for('projects.curr_proj', id=id))

    assigned_to_id = User.query.filter_by(email=assigned_to).first().id

    task = Task(description=description,
                state=state,
                priority=priority,
                in_project_id=in_project_id,
                assigned_to_id=assigned_to_id)

    db.session.add(task)
    db.session.commit()

    user = User.query.filter_by(email=assigned_to).first()

    user.tasks.append(task)
    db.session.commit()

    proj.tasks.append(task)
    db.session.commit()

    all_users = User.query.all()
    return render_template('curr_proj.html', project=proj, reg_us=all_users)
Esempio n. 2
0
    def create_task(self, parsed, data, splitnames=None):
        """Create a repository Task object.

        @param parsed: parsed information from HTML
        @type parsed: dict with fields name, source, description, type, files
        @param data: Data object
        @type data: repository.Data
        @param splitnames: names of splitfiles related to this task
        @type splitnames: list of strings
        @return: a repository Task object
        @rtype: repository.Task
        """
        if not data:
            return None

        name = 'task_' + parsed['name']
        obj = Task(
            pub_date=datetime.datetime.now(),
            name=name,
            description=parsed['description'],
            summary=parsed['summary'],
            version=1,
            is_public=False,
            is_current=True,
            user_id=1,
            license_id=1,
            performance_measure_id=1,
            data=data,
            tags=self._get_tags(parsed['tags']),
        )
        try:
            obj = self._add_slug(obj)
        except IntegrityError:
            self.warn('Slug already exists, skipping Task item ' + name + '!')
            self.problematic.append(name)
            return None
        self.progress('Creating Task item ' + obj.name + '.', 4)

        if parsed['task'] in ('Binary', 'MultiClass'):
            ttype = 'Classification'
        else:
            ttype = parsed['task']
        obj.type = ttype
        obj.save()

        self._add_taskdata(obj, splitnames)

        # obj needs pk first for many-to-many
        self._add_publications(obj, parsed['publications'])
        obj.is_public = True
        obj.save()

        return obj
Esempio n. 3
0
def assign_random_task(project):
    with open(project.repository.path, 'r') as f:
        parsed_json = json.load(f)
        for entry in parsed_json:
            print(entry)
            task = Task()
            task.project = project
            task.doer = recommend_random_doer()
            task.data = entry
            task.save()
Esempio n. 4
0
    def create_task(self, parsed, data, splitnames=None):
        """Create a repository Task object.

        @param parsed: parsed information from HTML
        @type parsed: dict with fields name, source, description, type, files
        @param data: Data object
        @type data: repository.Data
        @param splitnames: names of splitfiles related to this task
        @type splitnames: list of strings
        @return: a repository Task object
        @rtype: repository.Task
        """
        if not data:
            return None

        name = 'task_' + parsed['name']
        obj = Task(
            pub_date=datetime.datetime.now(),
            name=name,
            description=parsed['description'],
            summary=parsed['summary'],
            version=1,
            is_public=False,
            is_current=True,
            user_id=1,
            license_id=1,
            performance_measure_id=1,
            data=data,
            tags=self._get_tags(parsed['tags']),
        )
        try:
            obj = self._add_slug(obj)
        except IntegrityError:
            self.warn('Slug already exists, skipping Task item ' + name + '!')
            self.problematic.append(name)
            return None
        self.progress('Creating Task item ' + obj.name + '.', 4)

        if parsed['task'] in ('Binary', 'MultiClass'):
            ttype = 'Classification'
        else:
            ttype = parsed['task']
        obj.type=ttype
        obj.save()

        self._add_taskdata(obj, splitnames)

        # obj needs pk first for many-to-many
        self._add_publications(obj, parsed['publications'])
        obj.is_public = True
        obj.save()

        return obj
Esempio n. 5
0
    def __init__(self, *args, **kwargs):
        user = None
        if kwargs.has_key('request'):
            request = kwargs.pop('request')
        else:
            request = None

        super(ResultForm, self).__init__(*args, **kwargs)

        try:
            user = request.user
        except:
            user = None

        qs_task = Task().get_public_qs(user)
        self.fields['task'].queryset = Task.objects.filter(qs_task)
        qs_challenge = Challenge().get_public_qs(user)
        self.fields['challenge'].queryset = Challenge.objects.filter(
            qs_challenge)
        qs_method = Method().get_public_qs(user)
        self.fields['method'].queryset = Method.objects.filter(qs_method)
Esempio n. 6
0
 def clean_file(self):
     if self.cleaned_data['file'] and not Task.check_taskfile(self.cleaned_data['file']):
         raise forms.ValidationError( 'Format not supported' )
     return self.cleaned_data['file']  
Esempio n. 7
0
 def clean_file(self):
     if self.cleaned_data['file'] and not Task.check_taskfile(
             self.cleaned_data['file']):
         raise forms.ValidationError('Format not supported')
     return self.cleaned_data['file']