mirror of
https://github.com/AmanTahiliani/PeerNotes.git
synced 2026-08-07 11:55:12 -04:00
Added peer to existing file peers
This commit is contained in:
@@ -5,136 +5,136 @@ from django.db import migrations
|
||||
|
||||
def load_data_from_json(apps, schema_editor):
|
||||
topics = [
|
||||
"Introduction to Computer Science",
|
||||
"Programming Fundamentals",
|
||||
"Data Structures",
|
||||
"Algorithms",
|
||||
"Computer Architecture",
|
||||
"Operating Systems",
|
||||
"Database Systems",
|
||||
"Networking",
|
||||
"Software Engineering",
|
||||
"Artificial Intelligence",
|
||||
"Theory of Computation",
|
||||
"Compiler Design",
|
||||
"Distributed Systems",
|
||||
"Computer Graphics",
|
||||
"Cryptography",
|
||||
"Parallel and Concurrent Programming",
|
||||
"Human-Computer Interaction",
|
||||
"Computer Vision",
|
||||
"Web Technologies",
|
||||
"Embedded Systems",
|
||||
"Data Mining and Analytics",
|
||||
"Software Quality Assurance",
|
||||
"Ethical and Social Implications of Computing",
|
||||
"Advanced Topics",
|
||||
"Automata Theory",
|
||||
"Formal Languages and Automata",
|
||||
"Computational Complexity",
|
||||
"Graph Theory",
|
||||
"Computational Geometry",
|
||||
"Numerical Analysis",
|
||||
"Machine Learning",
|
||||
"Deep Learning",
|
||||
"Natural Language Processing",
|
||||
"Reinforcement Learning",
|
||||
"Computer Security",
|
||||
"Network Security",
|
||||
"Information Retrieval",
|
||||
"Cloud Computing",
|
||||
"IoT (Internet of Things)",
|
||||
"Virtual Reality",
|
||||
"Augmented Reality",
|
||||
"Mobile Application Development",
|
||||
"Game Development",
|
||||
"Computer Animation",
|
||||
"Operating System Design",
|
||||
"Real-Time Systems",
|
||||
"Concurrency Control",
|
||||
"Transaction Processing",
|
||||
"Data Warehousing",
|
||||
"Big Data Technologies",
|
||||
"Data Science",
|
||||
"Business Intelligence",
|
||||
"Quantum Computing",
|
||||
"Bioinformatics",
|
||||
"Computational Biology",
|
||||
"Robotics",
|
||||
"Computer Ethics",
|
||||
"Privacy and Security in Computing",
|
||||
"Digital Forensics",
|
||||
"Cryptocurrency and Blockchain",
|
||||
"Social Network Analysis",
|
||||
"Cloud Security",
|
||||
"Edge Computing",
|
||||
"Compiler Optimization",
|
||||
"High-Performance Computing",
|
||||
"Grid Computing",
|
||||
"Fuzzy Logic and Systems",
|
||||
"Expert Systems",
|
||||
"Pattern Recognition",
|
||||
"Knowledge Representation and Reasoning",
|
||||
"Semantic Web",
|
||||
"Computer Algebra Systems",
|
||||
"Geographic Information Systems",
|
||||
"Wireless Sensor Networks",
|
||||
"Biometric Authentication",
|
||||
"Internet Security Protocols",
|
||||
"Software Testing and Debugging",
|
||||
"Agile Methodologies",
|
||||
"DevOps",
|
||||
"Continuous Integration and Continuous Deployment (CI/CD)",
|
||||
"Model-Driven Engineering",
|
||||
"User Interface Design",
|
||||
"Accessibility in Computing",
|
||||
"User Experience (UX) Design",
|
||||
"Game Theory",
|
||||
"Social Computing",
|
||||
"Computational Sociology",
|
||||
"Computational Linguistics",
|
||||
"Music Information Retrieval",
|
||||
"Ethics in Artificial Intelligence",
|
||||
"Algorithmic Game Theory",
|
||||
"Behavioral Economics and Computing",
|
||||
"Neuroinformatics",
|
||||
"Health Informatics",
|
||||
"Geometric Modeling",
|
||||
"Scientific Computing",
|
||||
"Information Theory",
|
||||
"System Modeling and Simulation",
|
||||
"Decision Support Systems",
|
||||
"Database Security and Privacy",
|
||||
"Knowledge Management Systems",
|
||||
"Information Visualization",
|
||||
"Geospatial Data Analysis",
|
||||
"Enterprise Architecture",
|
||||
"Supply Chain Management Systems",
|
||||
"Data Integration and Interoperability",
|
||||
"Software Reuse and Component-Based Development",
|
||||
"Legal and Regulatory Issues in Computing",
|
||||
"Information Assurance",
|
||||
"Systems Analysis and Design",
|
||||
"E-commerce Systems",
|
||||
"E-learning Systems",
|
||||
"Human-Robot Interaction",
|
||||
"Biologically Inspired Computing",
|
||||
"Social Robotics",
|
||||
"Humanoid Robotics",
|
||||
"Computational Neuroscience",
|
||||
"Affective Computing",
|
||||
"Explainable AI",
|
||||
"Robot Ethics",
|
||||
"Cyber-Physical Systems",
|
||||
"Internet of Medical Things (IoMT)",
|
||||
"Quantum Information Science",
|
||||
"Quantum Cryptography",
|
||||
"Quantum Algorithms",
|
||||
"Quantum Machine Learning",
|
||||
"Quantum Error Correction",
|
||||
"Quantum Networking"
|
||||
]
|
||||
|
||||
"Introduction to Computer Science",
|
||||
"Programming Fundamentals",
|
||||
"Data Structures",
|
||||
"Algorithms",
|
||||
"Computer Architecture",
|
||||
"Operating Systems",
|
||||
"Database Systems",
|
||||
"Networking",
|
||||
"Software Engineering",
|
||||
"Artificial Intelligence",
|
||||
"Theory of Computation",
|
||||
"Compiler Design",
|
||||
"Distributed Systems",
|
||||
"Computer Graphics",
|
||||
"Cryptography",
|
||||
"Parallel and Concurrent Programming",
|
||||
"Human-Computer Interaction",
|
||||
"Computer Vision",
|
||||
"Web Technologies",
|
||||
"Embedded Systems",
|
||||
"Data Mining and Analytics",
|
||||
"Software Quality Assurance",
|
||||
"Ethical and Social Implications of Computing",
|
||||
"Advanced Topics",
|
||||
"Automata Theory",
|
||||
"Formal Languages and Automata",
|
||||
"Computational Complexity",
|
||||
"Graph Theory",
|
||||
"Computational Geometry",
|
||||
"Numerical Analysis",
|
||||
"Machine Learning",
|
||||
"Deep Learning",
|
||||
"Natural Language Processing",
|
||||
"Reinforcement Learning",
|
||||
"Computer Security",
|
||||
"Network Security",
|
||||
"Information Retrieval",
|
||||
"Cloud Computing",
|
||||
"IoT (Internet of Things)",
|
||||
"Virtual Reality",
|
||||
"Augmented Reality",
|
||||
"Mobile Application Development",
|
||||
"Game Development",
|
||||
"Computer Animation",
|
||||
"Operating System Design",
|
||||
"Real-Time Systems",
|
||||
"Concurrency Control",
|
||||
"Transaction Processing",
|
||||
"Data Warehousing",
|
||||
"Big Data Technologies",
|
||||
"Data Science",
|
||||
"Business Intelligence",
|
||||
"Quantum Computing",
|
||||
"Bioinformatics",
|
||||
"Computational Biology",
|
||||
"Robotics",
|
||||
"Computer Ethics",
|
||||
"Privacy and Security in Computing",
|
||||
"Digital Forensics",
|
||||
"Cryptocurrency and Blockchain",
|
||||
"Social Network Analysis",
|
||||
"Cloud Security",
|
||||
"Edge Computing",
|
||||
"Compiler Optimization",
|
||||
"High-Performance Computing",
|
||||
"Grid Computing",
|
||||
"Fuzzy Logic and Systems",
|
||||
"Expert Systems",
|
||||
"Pattern Recognition",
|
||||
"Knowledge Representation and Reasoning",
|
||||
"Semantic Web",
|
||||
"Computer Algebra Systems",
|
||||
"Geographic Information Systems",
|
||||
"Wireless Sensor Networks",
|
||||
"Biometric Authentication",
|
||||
"Internet Security Protocols",
|
||||
"Software Testing and Debugging",
|
||||
"Agile Methodologies",
|
||||
"DevOps",
|
||||
"Continuous Integration and Continuous Deployment (CI/CD)",
|
||||
"Model-Driven Engineering",
|
||||
"User Interface Design",
|
||||
"Accessibility in Computing",
|
||||
"User Experience (UX) Design",
|
||||
"Game Theory",
|
||||
"Social Computing",
|
||||
"Computational Sociology",
|
||||
"Computational Linguistics",
|
||||
"Music Information Retrieval",
|
||||
"Ethics in Artificial Intelligence",
|
||||
"Algorithmic Game Theory",
|
||||
"Behavioral Economics and Computing",
|
||||
"Neuroinformatics",
|
||||
"Health Informatics",
|
||||
"Geometric Modeling",
|
||||
"Scientific Computing",
|
||||
"Information Theory",
|
||||
"System Modeling and Simulation",
|
||||
"Decision Support Systems",
|
||||
"Database Security and Privacy",
|
||||
"Knowledge Management Systems",
|
||||
"Information Visualization",
|
||||
"Geospatial Data Analysis",
|
||||
"Enterprise Architecture",
|
||||
"Supply Chain Management Systems",
|
||||
"Data Integration and Interoperability",
|
||||
"Software Reuse and Component-Based Development",
|
||||
"Legal and Regulatory Issues in Computing",
|
||||
"Information Assurance",
|
||||
"Systems Analysis and Design",
|
||||
"E-commerce Systems",
|
||||
"E-learning Systems",
|
||||
"Human-Robot Interaction",
|
||||
"Biologically Inspired Computing",
|
||||
"Social Robotics",
|
||||
"Humanoid Robotics",
|
||||
"Computational Neuroscience",
|
||||
"Affective Computing",
|
||||
"Explainable AI",
|
||||
"Robot Ethics",
|
||||
"Cyber-Physical Systems",
|
||||
"Internet of Medical Things (IoMT)",
|
||||
"Quantum Information Science",
|
||||
"Quantum Cryptography",
|
||||
"Quantum Algorithms",
|
||||
"Quantum Machine Learning",
|
||||
"Quantum Error Correction",
|
||||
"Quantum Networking",
|
||||
]
|
||||
|
||||
Topic = apps.get_model("api", "Topic")
|
||||
Topic.objects.all().delete()
|
||||
for topic in topics:
|
||||
@@ -145,6 +145,7 @@ def load_data_from_json(apps, schema_editor):
|
||||
except Exception as e:
|
||||
print("Error:", str(e))
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
|
||||
@@ -64,6 +64,11 @@ urlpatterns = [
|
||||
views.DownvoteFile.as_view(),
|
||||
name="downvote-file",
|
||||
),
|
||||
path(
|
||||
"api/files/<int:file_id>/add-peer/",
|
||||
views.AddPeerToFile.as_view(),
|
||||
name="add-peer",
|
||||
),
|
||||
path("api/files/<int:pk>/", views.FileDetailAPIView.as_view(), name="file-detail"),
|
||||
path("api/report_user/", views.ReportUserView.as_view(), name="report-user"),
|
||||
path("api/register/", views.RegisterFile.as_view(), name="file-register"),
|
||||
|
||||
@@ -235,6 +235,31 @@ class RegisterFile(APIView):
|
||||
)
|
||||
|
||||
|
||||
class AddPeerToFile(APIView):
|
||||
authentication_classes = [TokenAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def post(self, request, file_id):
|
||||
try:
|
||||
user = request.user
|
||||
file = File.objects.get(id=file_id)
|
||||
print("File fetched")
|
||||
print(file)
|
||||
print(file.peer_users)
|
||||
if not file.peer_users.filter(id=user.id).exists():
|
||||
file.peer_users.add(user)
|
||||
file.save()
|
||||
return Response(
|
||||
f"User added to file with id {file.id}", status=status.HTTP_200_OK
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Error occured while adding peer to file: {e}")
|
||||
return Response(
|
||||
"Unable to register peer to given file id",
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
)
|
||||
|
||||
|
||||
class FileFilterView(APIView):
|
||||
authentication_classes = [TokenAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
@@ -282,7 +307,6 @@ class FileFilterView(APIView):
|
||||
queryset = queryset.filter(course__id=course_id)
|
||||
if semester_id:
|
||||
queryset = queryset.filter(semester__id=semester_id)
|
||||
|
||||
|
||||
queryset = queryset.annotate(
|
||||
upvote_count=Count("upvotes"), downvote_count=Count("downvotes")
|
||||
|
||||
Reference in New Issue
Block a user