harichselvamc commited on
Commit
98db750
·
verified ·
1 Parent(s): 9591786

Upload 8 files

Browse files
templates/admin_dashboard.html ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+ {% block content %}
3
+ <h2 class="text-center">Admin Dashboard</h2>
4
+
5
+ <!-- User Management Section -->
6
+ <div class="mt-4">
7
+ <h3>Manage Users</h3>
8
+
9
+ <!-- Add New User Form -->
10
+ <h5 class="mt-3">Add New User</h5>
11
+ <form method="POST" action="/admin/create_user" class="mb-4">
12
+ <div class="row">
13
+ <div class="col-md-3">
14
+ <input type="text" class="form-control" name="username" placeholder="Username" required>
15
+ </div>
16
+ <div class="col-md-3">
17
+ <input type="text" class="form-control" name="dob" placeholder="Date of Birth (YYYY-MM-DD)" required>
18
+ </div>
19
+ <div class="col-md-3">
20
+ <select class="form-control" name="role" required>
21
+ <option value="student">Student</option>
22
+ <option value="staff">Staff</option>
23
+ <option value="admin">Admin</option>
24
+ </select>
25
+ </div>
26
+ <div class="col-md-3">
27
+ <button type="submit" class="btn btn-primary">Add User</button>
28
+ </div>
29
+ </div>
30
+ </form>
31
+
32
+ <!-- Edit Existing User Section -->
33
+ <h5 class="mt-3">Edit User</h5>
34
+ {% if edit_user %}
35
+ <form method="POST" action="/admin/edit_user/{{ edit_user.id }}" class="mb-4">
36
+ <div class="row">
37
+ <div class="col-md-3">
38
+ <input type="text" class="form-control" name="username" value="{{ edit_user.username }}" required>
39
+ </div>
40
+ <div class="col-md-3">
41
+ <input type="text" class="form-control" name="dob" value="{{ edit_user.dob }}" required>
42
+ </div>
43
+ <div class="col-md-3">
44
+ <select class="form-control" name="role" required>
45
+ <option value="student" {% if edit_user.role == 'student' %}selected{% endif %}>Student</option>
46
+ <option value="staff" {% if edit_user.role == 'staff' %}selected{% endif %}>Staff</option>
47
+ <option value="admin" {% if edit_user.role == 'admin' %}selected{% endif %}>Admin</option>
48
+ </select>
49
+ </div>
50
+ <div class="col-md-3">
51
+ <button type="submit" class="btn btn-warning">Update User</button>
52
+ </div>
53
+ </div>
54
+ </form>
55
+ {% endif %}
56
+
57
+ <!-- User Table -->
58
+ <table class="table table-striped">
59
+ <thead>
60
+ <tr>
61
+ <th>ID</th>
62
+ <th>Username</th>
63
+ <th>Role</th>
64
+ <th>Date of Birth</th>
65
+ <th>Actions</th>
66
+ </tr>
67
+ </thead>
68
+ <tbody>
69
+ {% for user in users %}
70
+ <tr>
71
+ <td>{{ user.id }}</td>
72
+ <td>{{ user.username }}</td>
73
+ <td>{{ user.role }}</td>
74
+ <td>{{ user.dob }}</td>
75
+ <td>
76
+ <a href="/admin/edit_user/{{ user.id }}" class="btn btn-warning btn-sm">Edit</a>
77
+ <a href="/admin/delete_user/{{ user.id }}" class="btn btn-danger btn-sm">Delete</a>
78
+ </td>
79
+ </tr>
80
+ {% endfor %}
81
+ </tbody>
82
+ </table>
83
+ </div>
84
+
85
+ <!-- File Management Section -->
86
+ <div class="mt-4">
87
+ <h3>Manage Files</h3>
88
+ <table class="table table-striped">
89
+ <thead>
90
+ <tr>
91
+ <th>File Name</th>
92
+ <th>Subject</th>
93
+ <th>Author</th>
94
+ <th>Year</th>
95
+ <th>Actions</th>
96
+ </tr>
97
+ </thead>
98
+ <tbody>
99
+ {% for file in files %}
100
+ <tr>
101
+ <td>{{ file.file_name }}</td>
102
+ <td>{{ file.subject_name }}</td>
103
+ <td>{{ file.author_name }}</td>
104
+ <td>{{ file.year }}</td>
105
+ <td>
106
+ <a href="/uploads/{{ file.file_name }}" class="btn btn-success btn-sm">Download</a>
107
+ <a href="/delete/{{ file.id }}" class="btn btn-danger btn-sm">Delete</a>
108
+ </td>
109
+ </tr>
110
+ {% endfor %}
111
+ </tbody>
112
+ </table>
113
+ </div>
114
+
115
+ {% endblock %}
templates/base.html ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css">
7
+ <title>E-Content Sharing Platform</title>
8
+ </head>
9
+ <body>
10
+ <nav class="navbar navbar-expand-lg navbar-light bg-light">
11
+ <div class="container">
12
+ <a class="navbar-brand" href="/">E-Content</a>
13
+ <div class="collapse navbar-collapse">
14
+ <ul class="navbar-nav ms-auto">
15
+ {% if 'user_id' in session %}
16
+ <li class="nav-item"><a class="nav-link" href="/logout">Logout</a></li>
17
+ {% else %}
18
+ <li class="nav-item"><a class="nav-link" href="/login">Login</a></li>
19
+ {% endif %}
20
+ </ul>
21
+ </div>
22
+ </div>
23
+ </nav>
24
+ <div class="container mt-4">
25
+ {% block content %}{% endblock %}
26
+ </div>
27
+ </body>
28
+ </html>
templates/index.html CHANGED
The diff for this file is too large to render. See raw diff
 
templates/login.html ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+ {% block content %}
3
+ <h2 class="text-center">Login</h2>
4
+ <form method="POST" action="/login" class="mt-4">
5
+ <div class="mb-3">
6
+ <label for="username" class="form-label">Username (Enrollment/Employee No)</label>
7
+ <input type="text" class="form-control" id="username" name="username" required>
8
+ </div>
9
+ <div class="mb-3">
10
+ <label for="dob" class="form-label">Date of Birth (YYYY-MM-DD)</label>
11
+ <input type="text" class="form-control" id="dob" name="dob" required>
12
+ </div>
13
+ <button type="submit" class="btn btn-primary">Login</button>
14
+ </form>
15
+ {% endblock %}
templates/search_results.html ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+ {% block content %}
3
+ <h2 class="text-center">Search Results</h2>
4
+ <div class="mt-4">
5
+ <h3>Results</h3>
6
+ <table class="table table-striped">
7
+ <thead>
8
+ <tr>
9
+ <th>File Name</th>
10
+ <th>Subject</th>
11
+ <th>Author</th>
12
+ <th>Year</th>
13
+ <th>Download</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ {% for file in files %}
18
+ <tr>
19
+ <td>{{ file.file_name }}</td>
20
+ <td>{{ file.subject_name }}</td>
21
+ <td>{{ file.author_name }}</td>
22
+ <td>{{ file.year }}</td>
23
+ <td><a href="/uploads/{{ file.file_name }}" class="btn btn-success btn-sm">Download</a></td>
24
+ </tr>
25
+ {% endfor %}
26
+ </tbody>
27
+ </table>
28
+ </div>
29
+ {% endblock %}
templates/staff_dashboard.html ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+ {% block content %}
3
+ <h2 class="text-center">Staff Dashboard</h2>
4
+
5
+ <!-- All Available PDFs Section -->
6
+ <div class="mt-4">
7
+ <h3>All Available PDFs</h3>
8
+ <table class="table table-striped">
9
+ <thead>
10
+ <tr>
11
+ <th>File Name</th>
12
+ <th>Subject</th>
13
+ <th>Author</th>
14
+ <th>Year</th>
15
+ <th>Actions</th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ {% for file in all_files %}
20
+ <tr>
21
+ <td>{{ file.file_name }}</td>
22
+ <td>{{ file.subject_name }}</td>
23
+ <td>{{ file.author_name }}</td>
24
+ <td>{{ file.year }}</td>
25
+ <td>
26
+ <a href="/uploads/{{ file.file_name }}" class="btn btn-success btn-sm">Download</a>
27
+ <a href="/bookmark/{{ file.id }}" class="btn btn-warning btn-sm">
28
+ {% if file in bookmarked_files %}
29
+ Unbookmark
30
+ {% else %}
31
+ Bookmark
32
+ {% endif %}
33
+ </a>
34
+ </td>
35
+ </tr>
36
+ {% endfor %}
37
+ </tbody>
38
+ </table>
39
+ </div>
40
+
41
+ <!-- PDFs Uploaded by Staff Section -->
42
+ <div class="mt-4">
43
+ <h3>Your Uploaded PDFs</h3>
44
+ {% if user_uploaded_files %}
45
+ <table class="table table-striped">
46
+ <thead>
47
+ <tr>
48
+ <th>File Name</th>
49
+ <th>Subject</th>
50
+ <th>Author</th>
51
+ <th>Year</th>
52
+ <th>Actions</th>
53
+ </tr>
54
+ </thead>
55
+ <tbody>
56
+ {% for file in user_uploaded_files %}
57
+ <tr>
58
+ <td>{{ file.file_name }}</td>
59
+ <td>{{ file.subject_name }}</td>
60
+ <td>{{ file.author_name }}</td>
61
+ <td>{{ file.year }}</td>
62
+ <td>
63
+ <a href="/uploads/{{ file.file_name }}" class="btn btn-success btn-sm">Download</a>
64
+ <a href="/delete/{{ file.id }}" class="btn btn-danger btn-sm">Delete</a>
65
+ </td>
66
+ </tr>
67
+ {% endfor %}
68
+ </tbody>
69
+ </table>
70
+ {% else %}
71
+ <p>No PDFs uploaded by you yet.</p>
72
+ {% endif %}
73
+ </div>
74
+
75
+ <!-- Bookmarked PDFs Section -->
76
+ <div class="mt-4">
77
+ <h3>Your Bookmarked PDFs</h3>
78
+ {% if bookmarked_files %}
79
+ <table class="table table-striped">
80
+ <thead>
81
+ <tr>
82
+ <th>File Name</th>
83
+ <th>Subject</th>
84
+ <th>Author</th>
85
+ <th>Year</th>
86
+ <th>Actions</th>
87
+ </tr>
88
+ </thead>
89
+ <tbody>
90
+ {% for file in bookmarked_files %}
91
+ <tr>
92
+ <td>{{ file.file_name }}</td>
93
+ <td>{{ file.subject_name }}</td>
94
+ <td>{{ file.author_name }}</td>
95
+ <td>{{ file.year }}</td>
96
+ <td>
97
+ <a href="/uploads/{{ file.file_name }}" class="btn btn-success btn-sm">Download</a>
98
+ <a href="/bookmark/{{ file.id }}" class="btn btn-warning btn-sm">Unbookmark</a>
99
+ </td>
100
+ </tr>
101
+ {% endfor %}
102
+ </tbody>
103
+ </table>
104
+ {% else %}
105
+ <p>No PDFs bookmarked yet.</p>
106
+ {% endif %}
107
+ </div>
108
+
109
+ <!-- Upload New PDF Section -->
110
+ <div class="mt-4">
111
+ <h3>Upload a New PDF</h3>
112
+ <form method="POST" action="/upload" enctype="multipart/form-data">
113
+ <div class="mb-3">
114
+ <label for="file" class="form-label">File</label>
115
+ <input type="file" class="form-control" id="file" name="file" required>
116
+ </div>
117
+ <div class="mb-3">
118
+ <label for="subject_name" class="form-label">Subject Name</label>
119
+ <input type="text" class="form-control" id="subject_name" name="subject_name" required>
120
+ </div>
121
+ <div class="mb-3">
122
+ <label for="category" class="form-label">Category (Book/Material)</label>
123
+ <input type="text" class="form-control" id="category" name="category" required>
124
+ </div>
125
+ <div class="mb-3">
126
+ <label for="subject_code" class="form-label">Subject Code</label>
127
+ <input type="text" class="form-control" id="subject_code" name="subject_code" required>
128
+ </div>
129
+ <div class="mb-3">
130
+ <label for="year" class="form-label">Year</label>
131
+ <input type="text" class="form-control" id="year" name="year" required>
132
+ </div>
133
+ <div class="mb-3">
134
+ <label for="author_name" class="form-label">Author Name</label>
135
+ <input type="text" class="form-control" id="author_name" name="author_name" required>
136
+ </div>
137
+ <button type="submit" class="btn btn-primary">Upload</button>
138
+ </form>
139
+ </div>
140
+
141
+ {% endblock %}
templates/student_dashboard.html ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+ {% block content %}
3
+ <h2 class="text-center">Student Dashboard</h2>
4
+
5
+ <!-- All Available PDFs Section -->
6
+ <div class="mt-4">
7
+ <h3>All Available PDFs</h3>
8
+ <table class="table table-striped">
9
+ <thead>
10
+ <tr>
11
+ <th>File Name</th>
12
+ <th>Subject</th>
13
+ <th>Author</th>
14
+ <th>Year</th>
15
+ <th>Actions</th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ {% for file in all_files %}
20
+ <tr>
21
+ <td>{{ file.file_name }}</td>
22
+ <td>{{ file.subject_name }}</td>
23
+ <td>{{ file.author_name }}</td>
24
+ <td>{{ file.year }}</td>
25
+ <td>
26
+ <a href="/uploads/{{ file.file_name }}" class="btn btn-success btn-sm">Download</a>
27
+ <a href="/bookmark/{{ file.id }}" class="btn btn-warning btn-sm">
28
+ {% if file in bookmarked_files %}
29
+ Unbookmark
30
+ {% else %}
31
+ Bookmark
32
+ {% endif %}
33
+ </a>
34
+ </td>
35
+ </tr>
36
+ {% endfor %}
37
+ </tbody>
38
+ </table>
39
+ </div>
40
+
41
+ <!-- PDFs Uploaded by Student Section -->
42
+ <div class="mt-4">
43
+ <h3>Your Uploaded PDFs</h3>
44
+ {% if user_uploaded_files %}
45
+ <table class="table table-striped">
46
+ <thead>
47
+ <tr>
48
+ <th>File Name</th>
49
+ <th>Subject</th>
50
+ <th>Author</th>
51
+ <th>Year</th>
52
+ <th>Actions</th>
53
+ </tr>
54
+ </thead>
55
+ <tbody>
56
+ {% for file in user_uploaded_files %}
57
+ <tr>
58
+ <td>{{ file.file_name }}</td>
59
+ <td>{{ file.subject_name }}</td>
60
+ <td>{{ file.author_name }}</td>
61
+ <td>{{ file.year }}</td>
62
+ <td>
63
+ <a href="/uploads/{{ file.file_name }}" class="btn btn-success btn-sm">Download</a>
64
+ <a href="/delete/{{ file.id }}" class="btn btn-danger btn-sm">Delete</a>
65
+ </td>
66
+ </tr>
67
+ {% endfor %}
68
+ </tbody>
69
+ </table>
70
+ {% else %}
71
+ <p>No PDFs uploaded by you yet.</p>
72
+ {% endif %}
73
+ </div>
74
+
75
+ <!-- Bookmarked PDFs Section -->
76
+ <div class="mt-4">
77
+ <h3>Your Bookmarked PDFs</h3>
78
+ {% if bookmarked_files %}
79
+ <table class="table table-striped">
80
+ <thead>
81
+ <tr>
82
+ <th>File Name</th>
83
+ <th>Subject</th>
84
+ <th>Author</th>
85
+ <th>Year</th>
86
+ <th>Actions</th>
87
+ </tr>
88
+ </thead>
89
+ <tbody>
90
+ {% for file in bookmarked_files %}
91
+ <tr>
92
+ <td>{{ file.file_name }}</td>
93
+ <td>{{ file.subject_name }}</td>
94
+ <td>{{ file.author_name }}</td>
95
+ <td>{{ file.year }}</td>
96
+ <td>
97
+ <a href="/uploads/{{ file.file_name }}" class="btn btn-success btn-sm">Download</a>
98
+ <a href="/bookmark/{{ file.id }}" class="btn btn-warning btn-sm">Unbookmark</a>
99
+ </td>
100
+ </tr>
101
+ {% endfor %}
102
+ </tbody>
103
+ </table>
104
+ {% else %}
105
+ <p>No PDFs bookmarked yet.</p>
106
+ {% endif %}
107
+ </div>
108
+
109
+ <!-- Upload New PDF Section -->
110
+ <div class="mt-4">
111
+ <h3>Upload a New PDF</h3>
112
+ <form method="POST" action="/upload" enctype="multipart/form-data">
113
+ <div class="mb-3">
114
+ <label for="file" class="form-label">File</label>
115
+ <input type="file" class="form-control" id="file" name="file" required>
116
+ </div>
117
+ <div class="mb-3">
118
+ <label for="subject_name" class="form-label">Subject Name</label>
119
+ <input type="text" class="form-control" id="subject_name" name="subject_name" required>
120
+ </div>
121
+ <div class="mb-3">
122
+ <label for="category" class="form-label">Category (Book/Material)</label>
123
+ <input type="text" class="form-control" id="category" name="category" required>
124
+ </div>
125
+ <div class="mb-3">
126
+ <label for="subject_code" class="form-label">Subject Code</label>
127
+ <input type="text" class="form-control" id="subject_code" name="subject_code" required>
128
+ </div>
129
+ <div class="mb-3">
130
+ <label for="year" class="form-label">Year</label>
131
+ <input type="text" class="form-control" id="year" name="year" required>
132
+ </div>
133
+ <div class="mb-3">
134
+ <label for="author_name" class="form-label">Author Name</label>
135
+ <input type="text" class="form-control" id="author_name" name="author_name" required>
136
+ </div>
137
+ <button type="submit" class="btn btn-primary">Upload</button>
138
+ </form>
139
+ </div>
140
+
141
+ {% endblock %}
templates/upload.html ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+ {% block content %}
3
+ <h2 class="text-center">Upload File</h2>
4
+ <form method="POST" action="/upload" enctype="multipart/form-data" class="mt-4">
5
+ <div class="mb-3">
6
+ <label for="file" class="form-label">File</label>
7
+ <input type="file" class="form-control" id="file" name="file" required>
8
+ </div>
9
+ <div class="mb-3">
10
+ <label for="subject_name" class="form-label">Subject Name</label>
11
+ <input type="text" class="form-control" id="subject_name" name="subject_name" required>
12
+ </div>
13
+ <div class="mb-3">
14
+ <label for="category" class="form-label">Category (Book/Material)</label>
15
+ <input type="text" class="form-control" id="category" name="category" required>
16
+ </div>
17
+ <div class="mb-3">
18
+ <label for="subject_code" class="form-label">Subject Code</label>
19
+ <input type="text" class="form-control" id="subject_code" name="subject_code" required>
20
+ </div>
21
+ <div class="mb-3">
22
+ <label for="year" class="form-label">Year</label>
23
+ <input type="text" class="form-control" id="year" name="year" required>
24
+ </div>
25
+ <div class="mb-3">
26
+ <label for="author_name" class="form-label">Author Name</label>
27
+ <input type="text" class="form-control" id="author_name" name="author_name" required>
28
+ </div>
29
+ <button type="submit" class="btn btn-primary">Upload</button>
30
+ </form>
31
+ {% endblock %}