Esempio n. 1
0
 def test_post_request(self):
     project_type = ProjectType(name='project_type_1', comments='some comments')
     project_type.save()
     project = Project(
         project_type=project_type,
         base_project='base_project',
         work_project='work_project',
         project_url='some url',
         comments='comments related to this project',
     )
     project.save()
     event_type = EventType(name='EVENT_XYZ', comments='comments related to EVENT_XYZ')
     event_type.save()
     resp = self.client.post(
         '/api/events/',
         {
             'flow': 12,
             'event_type': event_type.name,
             'base_project': project.base_project,
             'work_project': project.work_project,
             'timestamp': '2015-11-12T15:16:17.000Z',
             'user': '******',
             'comments': 'some comments related to event'
         },
     )
     self.assertEqual(resp.status_code, HTTP_201_CREATED)
Esempio n. 2
0
    def full_clean(self, *args, **kwargs):
        if not self.project.token:
            self.project.token = Project.generate_token()[:50]

        ok, message = register_store(self.project)
        if not ok:
            raise ValidationError(message)
Esempio n. 3
0
    def handle(self, *args, **kwargs):
        path = kwargs['path']

        df = pd.read_csv(path)
        upper_range = len(df)
        print("Wait Data is being Loaded")

        try:
            proj = [
                Project(
                    program_id=Program.objects.get(
                        code=int(df['Programme Code'][row])),
                    name=(df['PROJECT/COMPONENT NAME'][row]).strip(),
                    code=df['Project/Component Code'][row],
                ) for row in range(0, upper_range)
            ]
            proj_data = Project.objects.bulk_create(proj)

            if proj_data:
                self.stdout.write('Successfully loaded Partner data ..')
            # for row in range(0, upper_range):
            #     print(df['Program Code'][row])
            #     print(Program.objects.get(code=int(df['Program Code'][row])))

        except Exception as e:
            print(e)
 def setUp(self):
     try:
         self.user = User.objects.get_by_natural_key(USER_NAME)
     except:
         self.user = User.objects.create_user(USER_NAME, USER_MAIL, USER_PASS)
     self.project = Project.newProject(PROJECT_NAME, self.user, PROJECT_URL, PROJECT_BUGTRACKER)
     self.issue = Issue.newIssue(self.project, ISSUE_KEY, ISSUE_TITLE, ISSUE_DESCRIPTION, self.project.createdByUser, self.project.trackerURL)
def _buildIssueFromDictionary(dict, user):
    check_noProject = dict.has_key('noProject')
    issue_trackerURL = dict['trackerURL']
    issue_projectId = dict['project_id']
    issue_projectName = dict.get('project_name', '')
    check_createProject = dict.has_key('createProject')
    newProject_name = dict.get('newProjectName', '')
    newProject_homeURL = dict.get('newProjectHomeURL', '')
    newProject_trackerURL = dict.get('newProjectTrackerURL', '')
    issue_key = dict.get('key', '')
    issue_title = dict.get('title', '')
    issue_description = dict.get('description', '')
    _throwIfIssueExists(issue_trackerURL, user)
    issue = None
    if (check_noProject):
        if (not issue_title or not issue_description):
            raise BaseException('title and description are required')

        issue = Issue.newIssueOrphan(issue_title, issue_description, user)
    else:
        project = None
        if (check_createProject):
            if (not newProject_name or not newProject_homeURL
                    or not newProject_trackerURL):
                raise BaseException(
                    'all parameters for new project are required')

            projectHomeURLValidationError = validateURL(newProject_homeURL)
            if (projectHomeURLValidationError):
                raise BaseException('invalid project URL (' +
                                    newProject_homeURL + ') - ' +
                                    projectHomeURLValidationError)

            projectTrackerURLValidationError = validateURL(
                newProject_trackerURL)
            if (projectTrackerURLValidationError):
                raise BaseException('invalid project tracker URL (' +
                                    newProject_trackerURL + ') - ' +
                                    projectTrackerURLValidationError)

            project = Project.newProject(newProject_name, user,
                                         newProject_homeURL,
                                         newProject_trackerURL)
        else:
            project = Project.objects.get(pk=int(issue_projectId))
            if (newProject_homeURL != project.homeURL):
                project.homeURL = newProject_homeURL

        if (not issue_key or not issue_title):
            raise BaseException('key and title are required')

        issueURLValidationError = validateIssueURL(issue_trackerURL)
        if (issueURLValidationError):
            raise BaseException('invalid issue URL (' + issue_trackerURL +
                                ') - ' + issueURLValidationError)

        issue = Issue.newIssue(project, issue_key, issue_title, user,
                               issue_trackerURL)
    return issue
Esempio n. 6
0
def _create_project(issueInfo, createdByUser):
    project = Project.newProject(issueInfo.project_name, createdByUser, '', issueInfo.project_trackerURL)
    project.save()
    notify_admin("INFO: Project created from json view", "issue key: "+issueInfo.key+"\n<br>"+ \
        "issue key: "+issueInfo.key+"\n<br>"+ \
        "project : "+project.name+"\n<br>"+ \
        "project.trackerURL: "+project.trackerURL+"\n<br>")
    return project
def _create_project(issueInfo, createdByUser):
    project = Project.newProject(issueInfo.project_name, createdByUser, '', issueInfo.project_trackerURL)
    project.save()
    notify_admin("INFO: Project created from json view", "issue key: "+issueInfo.key+"\n<br>"+ \
        "issue key: "+issueInfo.key+"\n<br>"+ \
        "project : "+project.name+"\n<br>"+ \
        "project.trackerURL: "+project.trackerURL+"\n<br>")
    return project
 def setUp(self):
     try:
         self.user = User.objects.get_by_natural_key(USER_NAME)
     except:
         self.user = User.objects.create_user(USER_NAME, USER_MAIL,
                                              USER_PASS)
     self.project = Project.newProject(PROJECT_NAME, self.user, PROJECT_URL,
                                       PROJECT_BUGTRACKER)
Esempio n. 9
0
    def __init__(self):
        # create dummy_user
        user_model = get_user_model()
        dummy_user = user_model.objects.create_user(
                'test_user_username',
                '*****@*****.**',
                'test_password'
        )
        dummy_user.save()
        self.dummy_user = dummy_user

        # create human contact
        dummy_human = Humans()
        dummy_human.user = dummy_user
        dummy_human.department = 'management'
        dummy_human.department = 'general-manager'
        dummy_human.phone = '0123456789'
        dummy_human.address = 'dummy user test address'
        dummy_human.personal_email = '*****@*****.**'
        dummy_human.enrolled = datetime.now()
        dummy_human.save()
        self.dummy_human = dummy_human

        # create a dummy client
        dummy_client = Client()
        dummy_client.name = 'test_client_name'
        dummy_client.manager = self.dummy_human
        dummy_client.save()
        self.dummy_client = dummy_client

        # create a dummy brand
        dummy_brand = Brand()
        dummy_brand.name = 'brand_test_name'
        dummy_brand.client = self.dummy_client
        dummy_brand.save()
        self.dummy_brand = dummy_brand

        # create a dummy project
        dummy_project = Project()
        dummy_project.name = 'test_project_name'
        dummy_project.short_code = "test_prj_dir_name"
        dummy_project.client = self.dummy_client
        dummy_project.brand = self.dummy_brand
        self.dummy_project = dummy_project
Esempio n. 10
0
def check_create_project(organization, user):
    try:
        project = Project.create(organization=organization,
                                 user=user,
                                 **DEFAULT_PROJECT_DATA)
    except:
        project = Project.objects.filter(
            organization=organization,
            name=DEFAULT_PROJECT_DATA['name']).first()
    return project
Esempio n. 11
0
 def test_post_raise_400_when_missing_base_project(self):
     project_type2 = ProjectType(name='project_type_2', comments='some comments')
     project_type2.save()
     project2 = Project(
         project_type=project_type2,
         base_project='base_project_5',
         work_project='work_project_5',
         project_url='some url',
         comments='comments related to this project',
     )
     project2.save()
     resp = self.client.post(
         '/api/flows/',
         {
             'number': 7,
             'work_project': project2.work_project,
             'timestamp': '2015-12-23T12:34:56.000Z',
             'status': 0,
             'comments': 'comments related to project',
         })
     self.assertEqual(resp.status_code, HTTP_400_BAD_REQUEST)
Esempio n. 12
0
 def test_project_permissions(
     self, user, request_method, project_id, is_leader=False
 ):
     project_kwargs = {}
     if not project_id and request_method == 'POST':
         return True
     elif type(project_id) == int or len(project_id) != 32:
         project_kwargs = {'id': project_id}
     else:
         project_kwargs = {'uuid': str(project_id)}
     return Project.shared_with_user(
         user, is_leader=is_leader
     ).filter(**project_kwargs).exists()
def _buildOfferFromDictionary(dict, user):
    check_noProject = dict.has_key('noProject')
    issue_trackerURL = dict['trackerURL']
    issue_projectId = dict['project_id']
    issue_projectName = dictOrEmpty(dict, 'project_name')
    check_createProject = dict.has_key('createProject')
    newProject_name = dictOrEmpty(dict, 'newProjectName')
    newProject_homeURL = dictOrEmpty(dict, 'newProjectHomeURL')
    newProject_trackerURL = dictOrEmpty(dict, 'newProjectTrackerURL')
    issue_key = dictOrEmpty(dict, 'key');
    issue_title = dictOrEmpty(dict, 'title');
    issue_description = dictOrEmpty(dict, 'description');

    _throwIfIssueExists(issue_trackerURL, user)

    issue = None
    if(check_noProject):
        if(not issue_title or not issue_description):
            raise BaseException('title and description are required')

        issue = Issue.newIssueOrphan(issue_title, issue_description, user)
    else:
        project = None
        if(check_createProject):
            if(not newProject_name or not newProject_homeURL or not newProject_trackerURL):
                raise BaseException('all parameters for new project are required')

            projectHomeURLValidationError = validateURL(newProject_homeURL)
            if(projectHomeURLValidationError):
                raise BaseException('invalid project URL ('+newProject_homeURL+') - '+projectHomeURLValidationError)

            projectTrackerURLValidationError = validateURL(newProject_trackerURL)
            if(projectTrackerURLValidationError):
                raise BaseException('invalid project tracker URL ('+newProject_trackerURL+') - '+projectTrackerURLValidationError)

            project = Project.newProject(newProject_name, user, newProject_homeURL, newProject_trackerURL)
        else:
            project = Project.objects.get(pk=int(issue_projectId))
            if(newProject_homeURL != project.homeURL):
                project.homeURL = newProject_homeURL

        if(not issue_key or not issue_title):
            raise BaseException('key and title are required')

        issueURLValidationError = validateIssueURL(issue_trackerURL)
        if(issueURLValidationError):
            raise BaseException('invalid issue URL ('+issue_trackerURL+') - '+issueURLValidationError)

        issue = Issue.newIssue(project, issue_key, issue_title, user, issue_trackerURL)

    return _buildOfferFromDictionary_and_issue(dict, user, issue);
Esempio n. 14
0
 def test_post_request(self):
     project_type = ProjectType(name='project_type_1', comments='some comments')
     project_type.save()
     project = Project(
         project_type=project_type,
         base_project='base_project_5',
         work_project='work_project_5',
         project_url='some url',
         comments='comments related to this project',
     )
     project.save()
     resp = self.client.post(
         '/api/flows/',
         {
             'number': 5,
             'base_project': project.base_project,
             'work_project': project.work_project,
             'timestamp': '2015-12-23T12:34:56.000Z',
             'status': 0,
             'comments': 'comments related to project',
         })
     self.assertEqual(resp.status_code, HTTP_201_CREATED)
     self.assertEqual(len(Flow.objects.filter(project=project)), 1)
    def create(self, validated_data):
        instance = Project(**validated_data)
        instance.creator = self.context['request'].user
        organization = self.get_organization()
        instance.organization = organization
        instance.save()

        ProjectContributor.objects.create(user=instance.organization.contact,
                                          project=instance,
                                          project_admin=True)
        return instance
Esempio n. 16
0
employees = ['Noah Smith', 'Olivia Black', 'Liam Lampros', 'Ava Campedelli']
for fullname in employees:
    first, last = fullname.split()
    employee = Employee()
    employee.user = User.objects.create_user(first_name=first,
                                             last_name=last,
                                             username=first.lower(),
                                             email='*****@*****.**' %
                                             first.lower(),
                                             password='******')
    employee.save()

projects = ['Project A', 'Project B', 'Project C', 'Project D', 'Project E']
employees = Employee.objects.all()
for project_name in projects:
    project = Project()
    project.name = project_name
    project.save()
    project.employees.add(*employees)

# yesterday, today and tomorrow
worked_days = [
    datetime.date.today() - datetime.timedelta(days=1),
    datetime.date.today(),
    datetime.date.today() + datetime.timedelta(days=1)
]
times = [0, 1, 2, 4, 6, 8]
for date in worked_days:
    for project in Project.objects.all():
        for employee in Employee.objects.all():
            hours = random.choice(times)
Esempio n. 17
0
 def get_queryset(self):
     if self.action == 'list':
         return Project.own_projects(self.request.user.id)
     return Project.objects.all()
 def setUp(self):
     try:
         self.user = User.objects.get_by_natural_key(USER_NAME)
     except:
         self.user = User.objects.create_user(USER_NAME, USER_MAIL, USER_PASS)
     self.project = Project.newProject(PROJECT_NAME, self.user, PROJECT_URL, PROJECT_BUGTRACKER)
Esempio n. 19
0
def create_project(request):
    project_name = request.POST.get("projectname")
    project_cost = request.POST.get("projectcost")
    p = Project(name=project_name, price_per_hour=project_cost)
    p.save()