2020-07-07 20:49:31 +08:00
|
|
|
# The core application of the Mia project.
|
|
|
|
# by imacat <imacat@mail.imacat.idv.tw>, 2020/7/4
|
|
|
|
|
|
|
|
# Copyright (c) 2020 imacat.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2020-07-08 07:24:36 +08:00
|
|
|
"""The views of the Mia core application.
|
2020-07-07 20:49:31 +08:00
|
|
|
|
|
|
|
"""
|
2020-08-16 18:15:28 +08:00
|
|
|
from typing import Dict, Type, Optional, Any
|
2020-08-13 15:43:04 +08:00
|
|
|
|
|
|
|
from dirtyfields import DirtyFieldsMixin
|
|
|
|
from django import forms
|
2020-08-09 14:07:47 +08:00
|
|
|
from django.contrib import messages
|
2020-07-06 23:06:45 +08:00
|
|
|
from django.contrib.auth import logout as logout_user
|
2020-08-09 14:07:47 +08:00
|
|
|
from django.contrib.messages.views import SuccessMessageMixin
|
2020-08-13 15:43:04 +08:00
|
|
|
from django.db.models import Model
|
2020-08-13 08:05:35 +08:00
|
|
|
from django.http import HttpResponse, JsonResponse, HttpRequest, \
|
2020-08-13 15:43:04 +08:00
|
|
|
HttpResponseRedirect, Http404
|
2020-08-09 22:08:15 +08:00
|
|
|
from django.shortcuts import redirect, render
|
2020-08-09 22:41:22 +08:00
|
|
|
from django.urls import reverse
|
2020-08-09 22:11:02 +08:00
|
|
|
from django.utils.decorators import method_decorator
|
2020-08-09 22:41:22 +08:00
|
|
|
from django.utils.translation import gettext_noop
|
2020-08-09 22:08:15 +08:00
|
|
|
from django.views.decorators.http import require_POST, require_GET
|
2020-08-09 20:47:53 +08:00
|
|
|
from django.views.generic import DeleteView as CoreDeleteView, ListView, \
|
|
|
|
DetailView
|
2020-08-13 15:43:04 +08:00
|
|
|
from django.views.generic.base import View
|
2020-08-09 20:22:37 +08:00
|
|
|
|
2020-08-13 15:43:04 +08:00
|
|
|
from . import stored_post, utils
|
2020-08-09 22:08:15 +08:00
|
|
|
from .digest_auth import login_required
|
|
|
|
from .forms import UserForm
|
|
|
|
from .models import User
|
2020-08-15 01:05:21 +08:00
|
|
|
from .utils import UrlBuilder
|
2020-08-13 15:43:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
class FormView(View):
|
|
|
|
"""The base form view."""
|
|
|
|
model: Type[Model] = None
|
2020-08-16 09:50:05 +08:00
|
|
|
form_class: Type[forms.Form] = None
|
2020-08-13 15:43:04 +08:00
|
|
|
template_name: str = None
|
|
|
|
context_object_name: str = "form"
|
|
|
|
success_url: str = None
|
2020-08-14 08:42:22 +08:00
|
|
|
error_url: str = None
|
2020-08-13 15:43:04 +08:00
|
|
|
not_modified_message: str = None
|
|
|
|
success_message: str = None
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
self._object = None
|
|
|
|
self._is_object_requested = False
|
|
|
|
|
2020-08-13 17:54:12 +08:00
|
|
|
def dispatch(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
|
|
|
|
"""The view to store an accounting transaction."""
|
2020-08-13 15:43:04 +08:00
|
|
|
if self.request.method != "POST":
|
2020-08-16 10:39:20 +08:00
|
|
|
return self.get(request, *args, **kwargs)
|
2020-08-13 17:53:15 +08:00
|
|
|
else:
|
2020-08-16 10:39:20 +08:00
|
|
|
return self.post(request, *args, **kwargs)
|
2020-08-13 17:53:15 +08:00
|
|
|
|
2020-08-16 10:39:20 +08:00
|
|
|
def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
|
2020-08-13 17:53:15 +08:00
|
|
|
"""Handles the GET requests."""
|
2020-08-16 13:20:18 +08:00
|
|
|
return render(self.request, self.get_template_name(),
|
|
|
|
self.get_context_data(**kwargs))
|
2020-08-13 17:53:15 +08:00
|
|
|
|
2020-08-16 10:39:20 +08:00
|
|
|
def post(self, request: HttpRequest, *args,
|
|
|
|
**kwargs) -> HttpResponseRedirect:
|
2020-08-13 17:53:15 +08:00
|
|
|
"""Handles the POST requests."""
|
2020-08-17 07:48:46 +08:00
|
|
|
form = self.get_form(**kwargs)
|
2020-08-13 17:53:15 +08:00
|
|
|
if not form.is_valid():
|
2020-08-16 18:31:02 +08:00
|
|
|
return self.form_invalid(form)
|
|
|
|
return self.form_valid(form)
|
|
|
|
|
2020-08-16 10:40:31 +08:00
|
|
|
def get_form_class(self) -> Type[forms.Form]:
|
|
|
|
"""Returns the form class."""
|
2020-08-16 09:50:05 +08:00
|
|
|
if self.form_class is None:
|
|
|
|
raise AttributeError("Please defined the form_class property.")
|
|
|
|
return self.form_class
|
2020-08-13 15:43:04 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def _model(self):
|
|
|
|
if self.model is None:
|
2020-08-13 19:33:17 +08:00
|
|
|
raise AttributeError("Please defined the model property.")
|
2020-08-13 15:43:04 +08:00
|
|
|
return self.model
|
|
|
|
|
2020-08-14 00:44:14 +08:00
|
|
|
def _set_object(self, obj: Model) -> None:
|
2020-08-13 15:43:04 +08:00
|
|
|
"""Sets the current object that we are operating."""
|
|
|
|
self._object = obj
|
|
|
|
self._is_object_requested = True
|
|
|
|
|
2020-08-14 00:44:14 +08:00
|
|
|
def _get_object(self) -> Optional[Model]:
|
2020-08-13 15:43:04 +08:00
|
|
|
"""Returns the current object that we are operating and cached."""
|
|
|
|
if not self._is_object_requested:
|
2020-08-14 00:44:14 +08:00
|
|
|
self._object = self.get_object()
|
2020-08-13 15:43:04 +08:00
|
|
|
self._is_object_requested = True
|
|
|
|
return self._object
|
|
|
|
|
2020-08-16 18:15:28 +08:00
|
|
|
def get_context_data(self, **kwargs) -> Dict[str, Any]:
|
2020-08-16 13:20:18 +08:00
|
|
|
"""Returns the context data for the template."""
|
|
|
|
return {self.context_object_name: self.get_form()}
|
|
|
|
|
2020-08-16 18:15:28 +08:00
|
|
|
def get_form(self, **kwargs) -> forms.Form:
|
2020-08-16 13:20:18 +08:00
|
|
|
"""Returns the form for the template."""
|
2020-08-17 07:48:46 +08:00
|
|
|
if self.request.method != "POST":
|
|
|
|
previous_post = stored_post.get_previous_post(self.request)
|
|
|
|
if previous_post is not None:
|
|
|
|
return self.make_form_from_post(previous_post)
|
|
|
|
obj = self.get_object()
|
|
|
|
if obj is not None:
|
|
|
|
return self.make_form_from_model(obj)
|
|
|
|
return self.get_form_class()()
|
|
|
|
else:
|
|
|
|
post = self.request.POST.dict()
|
|
|
|
utils.strip_post(post)
|
|
|
|
return self.make_form_from_post(post)
|
2020-08-16 13:20:18 +08:00
|
|
|
|
2020-08-13 15:43:04 +08:00
|
|
|
def get_template_name(self) -> str:
|
|
|
|
"""Returns the name of the template."""
|
|
|
|
if self.template_name is not None:
|
|
|
|
return self.template_name
|
|
|
|
if self.model is not None:
|
|
|
|
app_name = self.request.resolver_match.app_name
|
|
|
|
model_name = self.model.__name__.lower()
|
|
|
|
return F"{app_name}/{model_name}_form.html"
|
|
|
|
raise AttributeError(
|
2020-08-13 19:33:17 +08:00
|
|
|
"Please either define the template_name or the model property.")
|
2020-08-13 15:43:04 +08:00
|
|
|
|
|
|
|
def make_form_from_post(self, post: Dict[str, str]) -> forms.Form:
|
|
|
|
"""Creates and returns the form from the POST data."""
|
2020-08-16 09:55:59 +08:00
|
|
|
return self.get_form_class()(post)
|
2020-08-13 15:43:04 +08:00
|
|
|
|
|
|
|
def make_form_from_model(self, obj: Model) -> forms.Form:
|
|
|
|
"""Creates and returns the form from a data model."""
|
2020-08-16 09:55:59 +08:00
|
|
|
form_class = self.get_form_class()
|
|
|
|
return form_class({x: getattr(obj, x, None)
|
|
|
|
for x in form_class.base_fields})
|
2020-08-13 15:43:04 +08:00
|
|
|
|
|
|
|
def fill_model_from_form(self, obj: Model, form: forms.Form) -> None:
|
|
|
|
"""Fills in the data model from the form."""
|
2020-08-13 22:33:31 +08:00
|
|
|
for name in form.fields:
|
|
|
|
setattr(obj, name, form[name].value())
|
2020-08-13 15:43:04 +08:00
|
|
|
|
2020-08-16 19:00:47 +08:00
|
|
|
def form_invalid(self, form: forms.Form) -> HttpResponseRedirect:
|
2020-08-16 19:10:38 +08:00
|
|
|
"""Handles the action when the POST form is invalid."""
|
2020-08-16 18:58:25 +08:00
|
|
|
return stored_post.error_redirect(
|
|
|
|
self.request, self.get_error_url(), form.data)
|
|
|
|
|
2020-08-16 19:00:47 +08:00
|
|
|
def form_valid(self, form: forms.Form) -> HttpResponseRedirect:
|
2020-08-16 19:10:38 +08:00
|
|
|
"""Handles the action when the POST form is valid."""
|
2020-08-16 18:58:25 +08:00
|
|
|
obj = self.get_object()
|
|
|
|
if obj is None:
|
|
|
|
obj = self._model()
|
|
|
|
self._set_object(obj)
|
|
|
|
self.fill_model_from_form(obj, form)
|
|
|
|
if isinstance(obj, DirtyFieldsMixin)\
|
|
|
|
and not obj.is_dirty(check_relationship=True):
|
|
|
|
message = self.get_not_modified_message(form.cleaned_data)
|
|
|
|
else:
|
|
|
|
obj.save()
|
|
|
|
message = self.get_success_message(form.cleaned_data)
|
|
|
|
messages.success(self.request, message)
|
|
|
|
return redirect(str(UrlBuilder(self.get_success_url())
|
|
|
|
.query(r=self.request.GET.get("r"))))
|
|
|
|
|
2020-08-13 15:43:04 +08:00
|
|
|
def get_success_url(self) -> str:
|
|
|
|
"""Returns the URL on success."""
|
|
|
|
if self.success_url is not None:
|
|
|
|
return self.success_url
|
2020-08-14 00:44:14 +08:00
|
|
|
obj = self._get_object()
|
2020-08-13 15:43:04 +08:00
|
|
|
get_absolute_url = getattr(obj, "get_absolute_url", None)
|
|
|
|
if get_absolute_url is not None:
|
|
|
|
return get_absolute_url()
|
|
|
|
raise AttributeError(
|
2020-08-13 19:33:17 +08:00
|
|
|
"Please define either the success_url property,"
|
|
|
|
" the get_absolute_url method on the data model,"
|
2020-08-13 15:43:04 +08:00
|
|
|
" or the get_success_url method.")
|
|
|
|
|
2020-08-14 08:42:22 +08:00
|
|
|
def get_error_url(self) -> str:
|
|
|
|
"""Returns the URL on error"""
|
|
|
|
if self.error_url is not None:
|
|
|
|
return self.error_url
|
|
|
|
return self.request.get_full_path()
|
|
|
|
|
2020-08-16 10:46:59 +08:00
|
|
|
def get_not_modified_message(self, cleaned_data: Dict[str, str]) -> str:
|
|
|
|
"""Returns the message when the data was not modified.
|
2020-08-13 15:43:04 +08:00
|
|
|
|
2020-08-16 10:46:59 +08:00
|
|
|
Args:
|
|
|
|
cleaned_data: The cleaned data of the form.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
The message when the data was not modified.
|
|
|
|
"""
|
|
|
|
return self.not_modified_message % cleaned_data
|
|
|
|
|
|
|
|
def get_success_message(self, cleaned_data: Dict[str, str]) -> str:
|
|
|
|
"""Returns the success message.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
cleaned_data: The cleaned data of the form.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
The message when the data was not modified.
|
|
|
|
"""
|
|
|
|
return self.success_message % cleaned_data
|
2020-08-13 15:43:04 +08:00
|
|
|
|
2020-08-14 00:44:14 +08:00
|
|
|
def get_object(self) -> Optional[Model]:
|
2020-08-13 15:43:04 +08:00
|
|
|
"""Finds and returns the current object, or None on a create form."""
|
2020-08-14 00:40:23 +08:00
|
|
|
if "pk" in self.kwargs:
|
|
|
|
pk = self.kwargs["pk"]
|
2020-08-13 15:43:04 +08:00
|
|
|
try:
|
|
|
|
return self._model.objects.get(pk=pk)
|
|
|
|
except self._model.DoesNotExist:
|
|
|
|
raise Http404
|
|
|
|
return None
|
2020-08-09 14:07:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
class DeleteView(SuccessMessageMixin, CoreDeleteView):
|
|
|
|
"""The delete form view, with SuccessMessageMixin."""
|
|
|
|
|
|
|
|
def delete(self, request, *args, **kwargs):
|
|
|
|
response = super(DeleteView, self).delete(request, *args, **kwargs)
|
|
|
|
messages.success(request, self.get_success_message({}))
|
|
|
|
return response
|
2020-07-06 23:22:20 +08:00
|
|
|
|
|
|
|
|
2020-07-06 23:04:14 +08:00
|
|
|
@require_POST
|
2020-08-13 08:05:35 +08:00
|
|
|
def logout(request: HttpRequest) -> HttpResponseRedirect:
|
2020-07-06 23:04:14 +08:00
|
|
|
"""The view to log out a user.
|
|
|
|
|
|
|
|
Args:
|
2020-08-13 08:05:35 +08:00
|
|
|
request: The request.
|
2020-07-06 23:04:14 +08:00
|
|
|
|
|
|
|
Returns:
|
2020-08-13 08:05:35 +08:00
|
|
|
The redirect response.
|
2020-07-06 23:04:14 +08:00
|
|
|
"""
|
2020-07-06 23:06:45 +08:00
|
|
|
logout_user(request)
|
2020-07-06 23:04:14 +08:00
|
|
|
if "next" in request.POST:
|
|
|
|
request.session["logout"] = True
|
|
|
|
return redirect(request.POST["next"])
|
2020-08-09 19:08:47 +08:00
|
|
|
return redirect("home")
|
2020-07-09 23:18:37 +08:00
|
|
|
|
|
|
|
|
2020-08-09 22:11:02 +08:00
|
|
|
@method_decorator(require_GET, name="dispatch")
|
|
|
|
@method_decorator(login_required, name="dispatch")
|
2020-08-09 20:22:37 +08:00
|
|
|
class UserListView(ListView):
|
|
|
|
"""The view to list the users."""
|
|
|
|
queryset = User.objects.order_by("login_id")
|
|
|
|
|
|
|
|
|
2020-08-09 22:11:02 +08:00
|
|
|
@method_decorator(require_GET, name="dispatch")
|
|
|
|
@method_decorator(login_required, name="dispatch")
|
2020-08-09 20:47:53 +08:00
|
|
|
class UserView(DetailView):
|
|
|
|
"""The view of a user."""
|
|
|
|
def get_object(self, queryset=None):
|
2020-08-14 00:40:23 +08:00
|
|
|
return self.kwargs["user"]
|
2020-08-09 20:47:53 +08:00
|
|
|
|
|
|
|
|
2020-08-13 15:43:04 +08:00
|
|
|
@method_decorator(login_required, name="dispatch")
|
|
|
|
class UserFormView(FormView):
|
2020-08-16 09:46:23 +08:00
|
|
|
"""The form to create or update a user."""
|
2020-08-13 15:43:04 +08:00
|
|
|
model = User
|
2020-08-16 09:50:05 +08:00
|
|
|
form_class = UserForm
|
2020-08-13 15:43:04 +08:00
|
|
|
not_modified_message = gettext_noop("This user account was not changed.")
|
|
|
|
success_message = gettext_noop("This user account was saved successfully.")
|
2020-08-09 22:08:15 +08:00
|
|
|
|
2020-08-13 15:43:04 +08:00
|
|
|
def make_form_from_post(self, post: Dict[str, str]) -> UserForm:
|
|
|
|
"""Creates and returns the form from the POST data."""
|
|
|
|
form = UserForm(post)
|
2020-08-14 00:44:14 +08:00
|
|
|
form.user = self.get_object()
|
2020-08-13 15:43:04 +08:00
|
|
|
form.current_user = self.request.user
|
|
|
|
return form
|
2020-08-09 22:08:15 +08:00
|
|
|
|
2020-08-15 01:05:21 +08:00
|
|
|
def make_form_from_model(self, obj: User) -> UserForm:
|
2020-08-13 15:43:04 +08:00
|
|
|
"""Creates and returns the form from a data model."""
|
2020-08-09 22:08:15 +08:00
|
|
|
form = UserForm({
|
2020-08-13 15:43:04 +08:00
|
|
|
"login_id": obj.login_id,
|
|
|
|
"name": obj.name,
|
|
|
|
"is_disabled": obj.is_disabled,
|
2020-08-09 22:08:15 +08:00
|
|
|
})
|
2020-08-14 00:44:14 +08:00
|
|
|
form.user = self.get_object()
|
2020-08-13 15:43:04 +08:00
|
|
|
form.current_user = self.request.user
|
|
|
|
return form
|
2020-08-09 22:08:15 +08:00
|
|
|
|
2020-08-13 15:43:04 +08:00
|
|
|
def fill_model_from_form(self, obj: User, form: UserForm) -> None:
|
|
|
|
"""Fills in the data model from the form."""
|
|
|
|
obj.login_id = form["login_id"].value()
|
|
|
|
if form["password"].value() is not None:
|
|
|
|
obj.set_digest_password(
|
|
|
|
form["login_id"].value(), form["password"].value())
|
|
|
|
obj.name = form["name"].value()
|
|
|
|
obj.is_disabled = form["is_disabled"].value()
|
|
|
|
obj.current_user = self.request.user
|
2020-08-09 22:08:15 +08:00
|
|
|
|
2020-08-17 22:41:37 +08:00
|
|
|
def get_success_url(self) -> str:
|
|
|
|
"""Returns the URL on success."""
|
2020-08-17 22:49:37 +08:00
|
|
|
return reverse("mia_core:users.detail", args=[self.get_object()],
|
2020-08-17 22:41:37 +08:00
|
|
|
current_app=self.request.resolver_match.namespace)
|
|
|
|
|
2020-08-14 00:44:14 +08:00
|
|
|
def get_object(self) -> Optional[Model]:
|
2020-08-13 15:43:04 +08:00
|
|
|
"""Returns the current object, or None on a create form."""
|
2020-08-16 13:44:41 +08:00
|
|
|
return self.kwargs.get("user")
|
2020-08-09 22:41:22 +08:00
|
|
|
|
|
|
|
|
2020-08-09 22:53:56 +08:00
|
|
|
@require_POST
|
|
|
|
@login_required
|
2020-08-13 08:05:35 +08:00
|
|
|
def user_delete(request: HttpRequest, user: User) -> HttpResponseRedirect:
|
2020-08-09 22:53:56 +08:00
|
|
|
"""The view to delete an user.
|
|
|
|
|
|
|
|
Args:
|
2020-08-13 08:05:35 +08:00
|
|
|
request: The request.
|
|
|
|
user: The user.
|
2020-08-09 22:53:56 +08:00
|
|
|
|
|
|
|
Returns:
|
2020-08-13 08:05:35 +08:00
|
|
|
The response.
|
2020-08-09 22:53:56 +08:00
|
|
|
"""
|
|
|
|
message = None
|
|
|
|
if user.pk == request.user.pk:
|
|
|
|
message = gettext_noop("You cannot delete your own account.")
|
|
|
|
elif user.is_in_use():
|
|
|
|
message = gettext_noop(
|
|
|
|
"You cannot delete this account because it is in use.")
|
|
|
|
elif user.is_deleted:
|
|
|
|
message = gettext_noop("This account is already deleted.")
|
|
|
|
if message is not None:
|
|
|
|
messages.error(request, message)
|
|
|
|
return redirect("mia_core:users.detail", user)
|
|
|
|
user.delete()
|
|
|
|
message = gettext_noop("This user account was deleted successfully.")
|
|
|
|
messages.success(request, message)
|
|
|
|
return redirect("mia_core:users")
|
|
|
|
|
|
|
|
|
2020-08-15 01:05:21 +08:00
|
|
|
@method_decorator(login_required, name="dispatch")
|
|
|
|
class MyAccountFormView(UserFormView):
|
2020-08-16 09:46:23 +08:00
|
|
|
"""The form to update the information of the currently logged-in user."""
|
2020-08-15 01:05:21 +08:00
|
|
|
not_modified_message = gettext_noop("Your user account was not changed.")
|
|
|
|
success_message = gettext_noop("Your user account was saved successfully.")
|
2020-08-09 23:46:08 +08:00
|
|
|
|
2020-08-15 01:05:21 +08:00
|
|
|
def fill_model_from_form(self, obj: User, form: UserForm) -> None:
|
|
|
|
"""Fills in the data model from the form."""
|
|
|
|
obj.login_id = form["login_id"].value()
|
|
|
|
if form["password"].value() is not None:
|
|
|
|
obj.set_digest_password(
|
|
|
|
form["login_id"].value(), form["password"].value())
|
|
|
|
obj.name = form["name"].value()
|
|
|
|
obj.current_user = self.request.user
|
2020-08-09 23:46:08 +08:00
|
|
|
|
2020-08-15 01:05:21 +08:00
|
|
|
def get_success_url(self) -> str:
|
|
|
|
"""Returns the URL on success."""
|
2020-08-17 22:39:32 +08:00
|
|
|
return reverse("mia_core:my-account",
|
|
|
|
current_app=self.request.resolver_match.namespace)
|
2020-08-09 23:46:08 +08:00
|
|
|
|
2020-08-15 01:05:21 +08:00
|
|
|
def get_object(self) -> Optional[Model]:
|
|
|
|
"""Finds and returns the current object, or None on a create form."""
|
|
|
|
return self.request.user
|
2020-08-09 23:46:08 +08:00
|
|
|
|
2020-08-09 22:53:56 +08:00
|
|
|
|
2020-08-13 08:05:35 +08:00
|
|
|
def api_users_exists(request: HttpRequest, login_id: str) -> JsonResponse:
|
2020-08-09 22:08:15 +08:00
|
|
|
"""The view to check whether a user with a log in ID exists.
|
|
|
|
|
|
|
|
Args:
|
2020-08-13 08:05:35 +08:00
|
|
|
request: The request.
|
|
|
|
login_id: The log in ID.
|
2020-08-09 22:08:15 +08:00
|
|
|
|
|
|
|
Returns:
|
2020-08-13 08:05:35 +08:00
|
|
|
The response.
|
2020-08-09 22:08:15 +08:00
|
|
|
"""
|
|
|
|
try:
|
|
|
|
User.objects.get(login_id=login_id)
|
|
|
|
except User.DoesNotExist:
|
|
|
|
return JsonResponse(False, safe=False)
|
|
|
|
return JsonResponse(True, safe=False)
|