Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
login required added to multiple pages
  • Loading branch information
dtraviglia committed Oct 2, 2015
1 parent 111f4e1 commit 2b0c1906ca64486d1052075137014bc8a9b22787
Showing 8 changed files with 76 additions and 14 deletions.
@@ -2,8 +2,10 @@
from op_tasks.models import UserProfile
from django.core import mail
from django.conf import settings
from django.contrib.auth.decorators import login_required


@login_required(login_url='/tasking/login')
def send_email(request):
if request.method == 'POST':
email_to = request.POST.get('email_to', 'xdataonlineerrors@gmail.com')
@@ -20,8 +22,4 @@ def send_email(request):
statusMessage = "Email sent!"
elif status == 2:
statusMessage = ""
return render(request, 'email_form.html', {'userprofiles': userprofiles, 'status': status, 'statusMessage': statusMessage})


def printme(string):
print string
return render(request, 'email_form.html', {'userprofiles': userprofiles, 'status': status, 'statusMessage': statusMessage})
@@ -1,15 +1,21 @@
from django.shortcuts import render, redirect
from op_tasks.models import Product, Dataset
from django.contrib.auth.decorators import login_required

@login_required(login_url='/tasking/login')
def view_products(request):
products = Product.objects.all()
return render(request, 'products.html', {'products': products})


@login_required(login_url='/tasking/login')
def view_product_details(request, productname):
product = Product.objects.all().filter(name=productname)[0]
datasets = Dataset.objects.all()
return render(request, 'product_details.html', {'product': product, 'datasets': datasets})


@login_required(login_url='/tasking/login')
def edit_product(request, productpk):
product = Product.objects.get(id=productpk)
product.name = request.POST['product_name']
@@ -27,14 +33,20 @@ def edit_product(request, productpk):

return redirect('exp_portal:view_products')


@login_required(login_url='/tasking/login')
def manage_products(request):
products = Product.objects.all()
return render(request, 'products.html', {'products': products})


@login_required(login_url='/tasking/login')
def add_product(request):
datasets = Dataset.objects.all()
return render(request, 'add_product.html', {'datasets': datasets})


@login_required(login_url='/tasking/login')
def new_product(request):
product = Product(name=request.POST['product_name'])
product.url = request.POST['product_url']
@@ -3,23 +3,32 @@
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User

@login_required(login_url='/tasking/login')
def view_tasks(request):
tasks = OpTask.objects.all()
datasets = Dataset.objects.all()
return render(request, 'tasks.html', {'tasks': tasks, 'datasets':datasets})


@login_required(login_url='/tasking/login')
def view_completed(request):
completed_tasks = TaskListItem.objects.all().filter(task_complete=True).order_by('-date_complete')
return render(request, 'completed.html', {'completed_tasks': completed_tasks})


@login_required(login_url='/tasking/login')
def view_incomplete(request):
incomplete_tasks = TaskListItem.objects.all().filter(task_complete=False)
return render(request, 'incomplete.html', {'incomplete_tasks': incomplete_tasks})



@login_required(login_url='/tasking/login')
def add_task(request):
datasets = Dataset.objects.all()
return render(request, 'add_task.html', {'datasets': datasets})


@login_required(login_url='/tasking/login')
def new_task(request):
dataset = Dataset.objects.get(name=request.POST['task_dataset'])
task = OpTask()
@@ -32,9 +41,13 @@ def new_task(request):
task.save()
return redirect('exp_portal:view_tasks')


@login_required(login_url='/tasking/login')
def manage_tasks(request):
return view_tasks(request)


@login_required(login_url='/tasking/login')
def view_task_details(request, taskname):
task = OpTask.objects.all().filter(name=taskname)[0]
datasets = Dataset.objects.all()
@@ -43,6 +56,8 @@ def view_task_details(request, taskname):
print dataset.name
return render(request, 'task_details.html', {'task': task, 'datasets': datasets})


@login_required(login_url='/tasking/login')
def edit_task(request, taskpk):
task = OpTask.objects.get(id=taskpk)
task.name = request.POST['task_name']
@@ -59,6 +74,8 @@ def edit_task(request, taskpk):

return redirect('exp_portal:view_tasks')


@login_required(login_url='/tasking/login')
def delete_task(request, taskpk):
task = OpTask.objects.get(id=taskpk)
task.delete()
@@ -4,14 +4,18 @@
from django.contrib.auth.models import User
from django.http import JsonResponse

@login_required(login_url='/tasking/login')
def view_users(request):
userprofiles = UserProfile.objects.all().order_by('-user__last_login')
return render(request, 'users.html', {'userprofiles': userprofiles})

@login_required(login_url='/tasking/login')
def manage_users(request):
userprofiles = UserProfile.objects.all().order_by('-user__last_login')
return render(request, 'users.html', {'userprofiles': userprofiles})


@login_required(login_url='/tasking/login')
def edit_user(request, userprofilepk):
userprofile = UserProfile.objects.get(id=userprofilepk)
experiment = Experiment.objects.get(name=request.POST['experiment_name'])
@@ -20,11 +24,15 @@ def edit_user(request, userprofilepk):

return redirect('exp_portal:view_users')


@login_required(login_url='/tasking/login')
def add_user(request):
experiments = Experiment.objects.all()
products = Product.objects.all()
return render(request, 'add_user.html', {'experiments': experiments, 'products':products})


@login_required(login_url='/tasking/login')
def delete_user(request, userprofilepk):
userprofile = UserProfile.objects.get(id=userprofilepk)
user = userprofile.user
@@ -38,6 +46,8 @@ def delete_user(request, userprofilepk):

return redirect('exp_portal:view_users')


@login_required(login_url='/tasking/login')
def new_user(request):
user = User(username=request.POST['username'])
user.set_password(request.POST['password_1'])
@@ -97,9 +107,13 @@ def new_user(request):

return redirect('exp_portal:view_users')


@login_required(login_url='/tasking/login')
def user_added(request):
return render(request, 'user_added.html')


@login_required(login_url='/tasking/login')
def view_user_tasks(request, profile):
userprofile = UserProfile.objects.all().filter(user_hash=profile)[0]
usertasks = userprofile.tasklistitem_set.all()
@@ -115,6 +129,8 @@ def view_user_tasks(request, profile):

return render(request, 'user_tasks.html', {'userprofile': userprofile, 'experiments':experiments})


@login_required(login_url='/tasking/login')
def add_user_task(request, userpk):
userprofile = UserProfile.objects.get(id=userpk)
datasets = Dataset.objects.all()
@@ -123,6 +139,8 @@ def add_user_task(request, userpk):
return render(request, 'add_user_task.html', {'userprofile':userprofile,
'datasets': datasets, 'products': products, 'tasks': tasks})


@login_required(login_url='/tasking/login')
def update_user_tasks(request, userpk, datasetpk, productpk, taskpk):
dataset = Dataset.objects.get(id=datasetpk)
userprofile = UserProfile.objects.get(id=userpk)
@@ -138,6 +156,8 @@ def update_user_tasks(request, userpk, datasetpk, productpk, taskpk):

return redirect('exp_portal:add_user_task', userpk)


@login_required(login_url='/tasking/login')
def view_users_experiment(request, experiment_name):
experiment = Experiment.objects.get(name=experiment_name)
userprofiles = experiment.userprofile_set.all()
@@ -13,6 +13,8 @@
def home_page(request):
return render(request, 'experimenthome.html')


@login_required(login_url='/tasking/login')
def view_status(request):
experiments = Experiment.objects.all()
masterList = {}
@@ -49,16 +51,19 @@ def view_status(request):
return render(request, 'status.html', {'experimentList': masterList})


@login_required(login_url='/tasking/login')
def manage_exps(request):
experimentlist = Experiment.objects.all()
return render(request, 'experiments.html', {'experimentlist': experimentlist})


@login_required(login_url='/tasking/login')
def view_exp_details(request, exppk):
experiment = Experiment.objects.get(id=exppk)
return render(request, 'experiment_details.html', {'experiment':experiment})


@login_required(login_url='/tasking/login')
def add_exp(request):
if request.method == 'POST':
experiment = Experiment()
@@ -79,6 +84,7 @@ def add_exp(request):
return render(request, 'add_experiment.html')


@login_required(login_url='/tasking/login')
def edit_exp(request, exppk):
experiment = Experiment.objects.get(id=exppk)
experiment.name = request.POST['exp_name']
@@ -97,16 +103,19 @@ def edit_exp(request, exppk):
return redirect('exp_portal:manage_exps')


@login_required(login_url='/tasking/login')
def manage_datasets(request):
datasets = Dataset.objects.all()
return render(request, 'datasets.html', {'datasets':datasets})


@login_required(login_url='/tasking/login')
def view_dataset_details(request, datasetpk):
dataset = Dataset.objects.get(id=datasetpk)
return render(request, 'dataset_details.html', {'dataset':dataset})


@login_required(login_url='/tasking/login')
def add_dataset(request):
if request.method == 'POST':
# do update
@@ -121,6 +130,7 @@ def add_dataset(request):
return render(request, 'add_dataset.html')


@login_required(login_url='/tasking/login')
def edit_dataset(request, datasetpk):
dataset = Dataset.objects.get(id=datasetpk)
dataset.name = request.POST['dataset_name']
@@ -132,6 +142,7 @@ def edit_dataset(request, datasetpk):
return redirect('exp_portal:manage_datasets')


@login_required(login_url='/tasking/login')
def view_experiment_products(request):
experiments = Experiment.objects.all()
masterList = {}
@@ -44,6 +44,7 @@ def count_activities(session_id):
return len(timestamps)

# manages which prodct is delivered to the current user
@login_required(login_url='/tasking/login')
def product(request, task_pk):
if request.method == 'POST':
user = request.user
@@ -2,6 +2,7 @@
from op_tasks.models import Experiment
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required

import pandas
import numpy as np
@@ -11,6 +12,7 @@
from models import Document
from forms import DocumentForm

@login_required
def expuploads(request):
# Handle file uploads
if request.method == 'POST':
@@ -28,13 +30,14 @@ def expuploads(request):
return render(request, 'expuploads.html', {'form': form, 'experiments': experiments})

def handle_uploaded_file(f, dirname):
path = os.path.join('static/results/', dirname)
path = os.path.join('../static/results', dirname)
try:
os.mkdir(path)
except:
pass
os.makedirs(path)
except OSError as e:
print e
print 'unable to create directory ' + path
file = f['docfile']
with open(path + '/' + file.name, 'wb+') as destination:
with open(path + '/' + file.name, 'wb+') as destination:
for chunk in file.chunks():
destination.write(chunk)

@@ -54,7 +57,7 @@ def handle_uploaded_file(f, dirname):
tools = pandas.DataFrame(workingData['SYS.FIL.APP.']).drop_duplicates().sort('SYS.FIL.APP.').reset_index();
del tools['index']
tools.columns = ['Tools']
tools.to_json(path_or_buf=path + '\/' + "tools.json")
tools.to_json(path_or_buf=path + '/' + "tools.json")


metrics = {'load':{'col':'PST.EXP.CLD.CP.','max':5},
@@ -86,4 +89,4 @@ def handle_uploaded_file(f, dirname):
array.append(subarray)
d = pandas.DataFrame(array, columns=('Tool', 'Range'))
result = pandas.ordered_merge(df,d)
result.to_csv(path_or_buf=path + '\/' + str(key) + '.csv', sep=',',na_rep='0',index=False)
result.to_csv(path_or_buf=path + '/' + str(key) + '.csv', sep=',',na_rep='0',index=False)
@@ -10,7 +10,7 @@
# include urls for op_tasks and administration pages
url(r'^tasking/', include('op_tasks.urls', namespace="op_tasks")),
url(r'^experiment/', include('exp_portal.urls', namespace="exp_portal")),
url(r'^developer/', include('developer.urls', namespace="developer")),
# url(r'^developer/', include('developer.urls', namespace="developer")),
url(r'^user_feedback/', views.user_feedback_home, name='user_feedback_home'),
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('uploads.urls')),

0 comments on commit 2b0c190

Please sign in to comment.