Skip to content

Commit

Permalink
Revert "Added code for displaying users and admin portal changes"
Browse files Browse the repository at this point in the history
This reverts commit 67b8c79.
  • Loading branch information
matthewglanz committed Dec 2, 2023
1 parent 67b8c79 commit 66d4ae3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
17 changes: 1 addition & 16 deletions ACMAS/app/ACMAS_Web/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html

from .models import (Course, ModerationQueue, Question, University, UploadedFile, User)

Expand All @@ -19,24 +17,11 @@ def reject(modeladmin, request, queryset):
class ModerationQueueAdmin(admin.ModelAdmin):
actions = [approve, reject]

class UploadedFileAdmin(admin.ModelAdmin):
list_display = ('filename', 'file_dir', 'course', 'date_uploaded', 'flag', 'download', 'openPDF')

def download(self, obj):
url = reverse('download_file', kwargs={'pk': obj.pk})
return format_html('<a href="{}">Download</a>', url)
download.short_description = 'Download File'

def openPDF(self, obj):
url = reverse('pdfReader', kwargs={'url': obj.filename})
return format_html('<a href="{}">Open PDF</a>', url)
openPDF.short_description = 'Open PDF'


admin.site.register(Question)
admin.site.register(University)
admin.site.register(Course)
admin.site.register(UploadedFile, UploadedFileAdmin)
admin.site.register(UploadedFile)
admin.site.register(User)
admin.site.register(ModerationQueue, ModerationQueueAdmin)

Expand Down
2 changes: 0 additions & 2 deletions ACMAS/app/ACMAS_Web/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from django.urls import include, path

from . import views
from .views import download_file

urlpatterns = (
[
Expand All @@ -39,7 +38,6 @@
path("profile", views.profile, name="profile"),
path("password/", auth_views.PasswordChangeView.as_view()),
path("password/done/", auth_views.PasswordChangeDoneView.as_view()),
path('download_file/<int:pk>/', download_file, name='download_file'),
]
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Expand Down
9 changes: 0 additions & 9 deletions ACMAS/app/ACMAS_Web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

from django.contrib.auth.decorators import login_required
from django.core.cache import cache
from django.http import FileResponse
from django.shortcuts import redirect, render

from .forms import RegisterForm
from .models import UploadedFile
from .search import searchFacade
from .upload import createFacade
from django.shortcuts import get_object_or_404


def generateContext(request):
Expand Down Expand Up @@ -170,7 +168,6 @@ def pdfReader(request):
@login_required(login_url="/login")
def uploadFile(request):
context = generateContext(request)

school = request.POST.get("school") # Check to see if a school was entered
course = request.POST.get(
"course"
Expand Down Expand Up @@ -246,9 +243,3 @@ def register(request):
def profile(request):
context = generateContext(request)
return render(request, "profile.html", context)


def download_file(request, pk):
file = get_object_or_404(UploadedFile, pk=pk)
response = FileResponse(open(file.file_dir, 'rb'))
return response

0 comments on commit 66d4ae3

Please sign in to comment.