Exemplo n.º 1
0
def new_project(request):
    if request.method == 'POST':
        form = NewProjectForm(request.POST)

        if form.is_valid():
            # Create the respective crawler and project objects and add them to the database.
            current_crawler = Crawler(timespan_start=form.cleaned_data['timespan_start'],
                                      timespan_end=form.cleaned_data['timespan_end'],
                                      keywords=form.cleaned_data['keywords'],
                                      authors=form.cleaned_data['authors']
                                      )
            current_crawler.save()

            current_project = Project(owner=request.user,
                                      title=form.cleaned_data['title'],
                                      description=form.cleaned_data['description'],
                                      created=timezone.now(),
                                      crawler=current_crawler
                                      )
            current_project.save()
            current_project.managers.add(request.user)

            return redirect('dashboard')
        else:
            print(form.errors)

    # If a GET (or any other method) we'll create a blank form.
    else:
        form = NewProjectForm()

    return render(request,
                  'codegui/new_project.html',
                  {'form': form})
Exemplo n.º 2
0
    def _create_data(self):
        u1 = User.objects.create_user('valerio', '*****@*****.**', 'valerio')
        u1.save()

        u2 = User.objects.create_user('bob', '*****@*****.**', 'bob')
        u2.save()

        p1 = Project(owner=u1,
                     name='Italian case 2013',
                     description='all tweets about pasta sent in March 2013',
                     status=Project.READY)
        p1.save()
        p1.coders.add(u1)
        p1.save()

        p2 = Project(owner=u1,
                     name='Italian case 2015',
                     description='all tweets about pizza sent in July 2015')
        p2.save()
        p2.coders.add(u1)
        p2.coders.add(u2)
        p2.save()

        # reading tweets for project p1
        messages = read_tweets_from_file('../data/pizza1000.json')
        index = 0

        for message in messages:
            new_author, created = Author.objects.get_or_create(username=message['author'],
                                                               source=message['source'])

            new_message = Message(author=new_author,
                                  source=message['source'],
                                  timestamp=message['timestamp'])
            new_message.project=p1
            new_message.index = index
            index += 1
            new_message.save()

        v1 = Variable(project=p1,
                      name='subjective',
                      description='Describes whether the message is a personal ' \
                             'opinion or a neutral information.')
        v1.save()

        c1 = Category(variable=v1,
                      value='subjective',
                      label='The message is subjective.')
        c1.save()

        c2 = Category(variable=v1,
                      value='objective',
                      label='The message is objective.')
        c2.save()
Exemplo n.º 3
0
    def create_projects(self):
        u1 = User.objects.get(username='******')
        for x in range(1, 2):
            new_project = Project(owner=u1,
                                  title='Twitter demo 2015',
                                  description='A demo about twitter data concerning pizza tweets.')
            new_project.save()
            new_project.managers.add(u1)

        p1 = Project.objects.get(title='Twitter demo 2015')
        for x in range(1, 26):
            user = User.objects.filter(username='******'+str(x))
            p1.coders.add(*user)
        p1.save()
Exemplo n.º 4
0
    def _create_data(self):
        u1 = User.objects.create_user('valerio', '*****@*****.**', 'valerio')
        u1.save()

        u2 = User.objects.create_user('bob', '*****@*****.**', 'bob')
        u2.save()

        p1 = Project(owner=u1,
                     name='Italian case 2013',
                     description='all tweets about pasta sent in March 2013',
                     status=Project.READY)
        p1.save()
        p1.coders.add(u1)
        p1.save()

        p2 = Project(owner=u1,
                     name='Italian case 2015',
                     description='all tweets about pizza sent in July 2015')
        p2.save()
        p2.coders.add(u1)
        p2.coders.add(u2)
        p2.save()

        self.load_tweets_into(p1)
        self.create_progress_for(p1)

        v1 = Variable(project=p1,
                      name='subjective',
                      description='Describes whether the message is a personal ' \
                             'opinion or a neutral information.')
        v1.save()

        c1 = Category(variable=v1,
                      value='subjective',
                      label='The message is subjective.')
        c1.save()

        c2 = Category(variable=v1,
                      value='objective',
                      label='The message is objective.')
        c2.save()