[Enhancement] Swappable Packages (#216)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#216
Reviewed-by: liambrydon <lbry121@aucklanduni.ac.nz>
Reviewed-by: Tobias O <tobias.olenyi@envipath.com>
This commit is contained in:
2025-11-14 21:42:39 +13:00
parent d584791ee8
commit a8554c903c
22 changed files with 239 additions and 179 deletions

View File

@ -1,27 +1,30 @@
from typing import List, Dict, Optional, Any
from typing import Any, Dict, List, Optional
from django.conf import settings as s
from django.contrib.auth import get_user_model
from django.http import HttpResponse
from django.shortcuts import redirect
from ninja import Router, Schema, Field, Form
from ninja import Field, Form, Router, Schema
from utilities.chem import FormatConverter
from .logic import PackageManager, UserManager, SettingManager
from .logic import PackageManager, SettingManager, UserManager
from .models import (
Compound,
CompoundStructure,
Package,
Edge,
Node,
Pathway,
Reaction,
Rule,
Scenario,
SimpleAmbitRule,
User,
UserPackagePermission,
Rule,
Reaction,
Scenario,
Pathway,
Node,
Edge,
SimpleAmbitRule,
)
Package = s.GET_PACKAGE_MODEL()
def _anonymous_or_real(request):
if request.user.is_authenticated and not request.user.is_anonymous:
@ -123,8 +126,7 @@ class SimpleEdge(SimpleObject):
################
@router.post("/", response={200: SimpleUser, 403: Error})
def login(request, loginusername: Form[str], loginpassword: Form[str]):
from django.contrib.auth import authenticate
from django.contrib.auth import login
from django.contrib.auth import authenticate, login
email = User.objects.get(username=loginusername).email
user = authenticate(username=email, password=loginpassword)