-
Notifications
You must be signed in to change notification settings - Fork 26
/
files.py
39 lines (36 loc) · 1.43 KB
/
files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from helpers import *
from models import *
import bforms
import time
import hmac
import sha
import base64
import secrets
import defaults
import S3
@login_required
def files(request, project_name):
"""Files for a project. Shows the files uploaded for a project.
Actions available:
Add files: Owner Participant
"""
project = get_project(request, project_name)
gen = S3.QueryStringAuthGenerator(secrets.AWS_ID, secrets.AWS_SECRET_KEY)
addfileform = bforms.AddFileForm(project = project, user = request.user)
if request.method == 'POST':
if request.POST.has_key('Addfile'):
addfileform = bforms.AddFileForm(project , request.user, request.POST, request.FILES)
if addfileform.is_valid():
addfileform.save()
return HttpResponseRedirect('.')
if request.POST.has_key('fileid'):
fileid = int(request.POST['fileid'])
file = ProjectFile.objects.get(project = project, id = fileid)
conn = S3.AWSAuthConnection(secrets.AWS_ID, secrets.AWS_SECRET_KEY)
for revision in file.projectfileversion_set.all():
conn.delete(defaults.bucket, revision.revision_name)
file.delete()
payload = locals()
return render(request, 'project/files.html', payload)