Exemplo n.º 1
0
def _save_report(report_type, member, team, message):
    standup = team.todays_standup()
    if standup is None:
        standup = Standup(team_id=team.id)
        standup.created_at = datetime.now()
        standup.save()

    report = member.todays_report(standup)
    if report is None:
        report = Report(member_id=member.id, standup_id=standup.id)
        report.created_at = datetime.now()
        report.save()

    if report_type == 'today':
        report.today = message
    elif report_type == 'yesterday':
        report.yesterday = message
    elif report_type == 'problem':
        report.problem = message

    report.updated_at = datetime.now()
    report.save()

    standup.update_at = datetime.now()
    standup.save()

    return 'Rapportert til `{}`'.format(team.name)
Exemplo n.º 2
0
def cpanel_submit(request):
    # The user adding the request
    user = request.user

    name = request.POST['name']
    phone = request.POST['phone']
    email = request.POST['email']
    type = request.POST['device']
    os = request.POST['os']
    problem = request.POST['problem']
    description = request.POST['description']
    deviceObj = Device()
    report = Report()
    usersWithSameEmail = User.objects.filter(email=email)
    reportUser = User()

    userFound = False
    for u in usersWithSameEmail:
        # If user exists, don't create a new one
        if u.email == email:
            reportUser = u
            userFound = True

    if not userFound:
        reportUser.email = email
        reportUser.username = name
        reportUser.password = '******'
        reportUser.save()

    # Get the devices the user has
    usersDevices = Device.objects.filter(owner=reportUser)

    deviceFound = False
    for d in usersDevices:
        # If the device exists recognize it, and use it
        if d.os == os and d.type == type:
            deviceObj = d
            deviceFound = True

    if not deviceFound:
        # Generate device object
        deviceObj.owner = reportUser
        deviceObj.os = os
        deviceObj.type = type
        deviceObj.save()

    # Generate Report
    report.owner = reportUser
    report.device = deviceObj
    report.description = description
    report.problem = problem
    report.completed = False
    report.save()

    # Generate initial status
    status = Status()
    status.report = report
    # Checked in message
    status.message = 'c'
    status.tech = user
    status.save()

    return cpanel(request, True)
Exemplo n.º 3
0
def cpanel_submit(request):
	# The user adding the request
	user = request.user

	name = request.POST['name']
	phone = request.POST['phone']
	email = request.POST['email']
	type = request.POST['device']
	os = request.POST['os']
	problem = request.POST['problem']
	description = request.POST['description']
	deviceObj = Device()
	report = Report()
	usersWithSameEmail = User.objects.filter(email=email)
	reportUser = User()

	userFound = False
	for u in usersWithSameEmail:
		# If user exists, don't create a new one
		if u.email == email:
			reportUser = u
			userFound = True

	if not userFound:
		reportUser.email = email
		reportUser.username = name
		reportUser.password = '******'
		reportUser.save()

	# Get the devices the user has
	usersDevices = Device.objects.filter(owner=reportUser)

	deviceFound = False
	for d in usersDevices:
		# If the device exists recognize it, and use it
		if d.os == os and d.type == type:
			deviceObj = d
			deviceFound = True

	if not deviceFound:
		# Generate device object
		deviceObj.owner = reportUser
		deviceObj.os = os
		deviceObj.type = type
		deviceObj.save()

	# Generate Report
	report.owner = reportUser
	report.device = deviceObj
	report.description = description
	report.problem = problem
	report.completed = False
	report.save()

	# Generate initial status
	status = Status()
	status.report = report
	# Checked in message
	status.message = 'c'
	status.tech = user
	status.save()

	return cpanel(request, True)