Ejemplo n.º 1
0
def page_project(request, project_uuid):
    try:
        #LOL @ this try. why is this on profile lol
        user_profile = request.user.get_profile()
        users_teams = user_profile.teams.all()
    except:
        raise Http404

    try:
        # lol security, add later
        project = Project.objects.get(project_uuid, team__in=[users_teams])
    except Project.DoesNotExist:
        raise Http404

    #lol at this. f**k. no time to do this right
    try:
        start_date = datetime.now()
        assignments = date_range_assignments(start_date, start_date, project=project)
        assignment = assignments[0]
    except Exception:
        raise Http404


    #F**K IT WRAPPPP EVERYTHING IN EXCEPTS (10 minutes left)
    try:
        dest_user = assignment.primary_contact
    except Exception:
        dest_user = None

    if dest_user:
        message = "You have been paged by a team member on the {0} team.".format(project.name)
        try:
            new_notify = Notification(project=project, message=message, recipient=dest_user, notification_type=user_profile.contact_method)
            new_notify.save()
        except Exception:
            raise Http404
#        else:
#            send_notification(new_notify.uuid)
    return HttpResponse('wut')
Ejemplo n.º 2
0
def assignment_view(request, project_uuid, year=None, month=None, template_name="scheduler/assignment_json.html"):
    if request.user.is_authenticated():
        teams = request.user.profile.teams.all

    # If we're not passed a date, get the assignments for the current month
    now = datetime.datetime.now()

    start_year = year
    start_month = month
    if year is None:
        start_year = now.year

    if month is None:
        start_month = now.month

    start_date = datetime.datetime(start_year, start_month, 1)

    if start_month < 12:
        end_year = start_year
        end_month = start_month + 1

    else:
        end_year = start_year + 1
        end_month = 1

    end_date = datetime.datetime(end_year, end_month, 1)

    epoch_start = request.REQUEST.get('start',None)
    epoch_end = request.REQUEST.get('end', None)

    if epoch_start and epoch_end:
        start_date = datetime.datetime.fromtimestamp(float(epoch_start))
        end_date = datetime.datetime.fromtimestamp(float(epoch_end))
    assignments = (date_range_assignments(start_date, end_date, None, teams ))
    data = { 'start_date': start_date, 'end_date': end_date, 'assignments': assignments }
    return render_to_response(template_name, data, context_instance = RequestContext(request))