Move current user views to the user management app

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-04-17 02:25:57 -04:00
parent 97a9d21ac4
commit 54020a8813
17 changed files with 124 additions and 114 deletions
+3 -6
View File
@@ -25,10 +25,9 @@ from .handlers import (
user_locale_profile_session_config, user_locale_profile_create
)
from .links import (
link_about, link_check_version, link_current_user_details,
link_current_user_edit, link_current_user_locale_profile_edit,
link_about, link_check_version, link_current_user_locale_profile_edit,
link_license, link_object_error_list_clear, link_packages_licenses,
link_setup, link_tools, separator_user_label, text_user_label
link_setup, link_tools
)
from .literals import DELETE_STALE_UPLOADS_INTERVAL, MESSAGE_SQLITE_WARNING
@@ -135,10 +134,8 @@ class CommonApp(MayanAppConfig):
)
menu_user.bind_links(
links=(
separator_user_label, text_user_label,
link_current_user_details, link_current_user_edit,
link_current_user_locale_profile_edit,
)
), position=50
)
menu_about.bind_links(
-22
View File
@@ -5,7 +5,6 @@ import os
from django import forms
from django.conf import settings
from django.contrib.admin.utils import label_for_field
from django.contrib.auth import get_user_model
from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured
from django.db import models
from django.utils.module_loading import import_string
@@ -303,24 +302,3 @@ class PackagesLicensesForm(FileDisplayForm):
self.fields['text'].initial = '\n\n'.join(
['{}\n{}'.format(package.label, package.license_text) for package in Package.get_all()]
)
class UserForm(forms.ModelForm):
"""
Form used to edit an user's mininal fields by the user himself
"""
class Meta:
fields = ('username', 'first_name', 'last_name', 'email')
model = get_user_model()
class UserForm_view(DetailForm):
"""
Form used to display an user's public details
"""
class Meta:
fields = (
'username', 'first_name', 'last_name', 'email', 'last_login',
'date_joined', 'groups'
)
model = get_user_model()
-2
View File
@@ -6,8 +6,6 @@ icon_about = Icon(driver_name='fontawesome', symbol='info')
icon_assign_remove_add = Icon(driver_name='fontawesome', symbol='plus')
icon_assign_remove_remove = Icon(driver_name='fontawesome', symbol='minus')
icon_check_version = Icon(driver_name='fontawesome', symbol='sync')
icon_current_user_details = Icon(driver_name='fontawesome', symbol='user')
icon_current_user_edit = Icon(driver_name='fontawesome', symbol='user')
icon_current_user_locale_profile_details = Icon(
driver_name='fontawesome', symbol='globe'
)
+1 -14
View File
@@ -4,18 +4,15 @@ from django.apps import apps
from django.utils.translation import ugettext_lazy as _
from mayan.apps.navigation import Link
from mayan.apps.navigation.classes import Separator, Text
from .icons import (
icon_about, icon_check_version, icon_current_user_details,
icon_current_user_edit, icon_current_user_locale_profile_details,
icon_about, icon_check_version, icon_current_user_locale_profile_details,
icon_current_user_locale_profile_edit, icon_documentation,
icon_forum, icon_license, icon_object_error_list_with_icon,
icon_packages_licenses, icon_setup, icon_source_code, icon_support,
icon_tools
)
from .permissions_runtime import permission_error_log_view
from .utils import get_user_label_text
def get_kwargs_factory(variable_name):
@@ -43,14 +40,6 @@ link_check_version = Link(
icon_class=icon_check_version, text=_('Check for updates'),
view='common:check_version_view'
)
link_current_user_details = Link(
icon_class=icon_current_user_details, text=_('User details'),
view='common:current_user_details'
)
link_current_user_edit = Link(
icon_class=icon_current_user_edit, text=_('Edit details'),
view='common:current_user_edit'
)
link_current_user_locale_profile_details = Link(
icon_class=icon_current_user_locale_profile_details,
text=_('Locale profile'),
@@ -106,5 +95,3 @@ link_support = Link(
link_tools = Link(
icon_class=icon_tools, text=_('Tools'), view='common:tools_list'
)
separator_user_label = Separator()
text_user_label = Text(text=get_user_label_text)
+3 -12
View File
@@ -7,10 +7,9 @@ from .api_views import (
APIContentTypeList, APITemplateDetailView, APITemplateListView
)
from .views import (
AboutView, CheckVersionView, CurrentUserDetailsView, CurrentUserEditView,
CurrentUserLocaleProfileDetailsView, CurrentUserLocaleProfileEditView,
FaviconRedirectView, HomeView, LicenseView,
ObjectErrorLogEntryListClearView, ObjectErrorLogEntryListView,
AboutView, CheckVersionView, CurrentUserLocaleProfileDetailsView,
CurrentUserLocaleProfileEditView, FaviconRedirectView, HomeView,
LicenseView, ObjectErrorLogEntryListClearView, ObjectErrorLogEntryListView,
PackagesLicensesView, RootView, SetupListView, ToolsListView,
multi_object_action_view
)
@@ -34,14 +33,6 @@ urlpatterns = [
),
url(regex=r'^setup/$', view=SetupListView.as_view(), name='setup_list'),
url(regex=r'^tools/$', view=ToolsListView.as_view(), name='tools_list'),
url(
regex=r'^user/$', view=CurrentUserDetailsView.as_view(),
name='current_user_details'
),
url(
regex=r'^user/edit/$', view=CurrentUserEditView.as_view(),
name='current_user_edit'
),
url(
regex=r'^user/locale/$',
view=CurrentUserLocaleProfileDetailsView.as_view(),
-8
View File
@@ -13,7 +13,6 @@ from django.utils.http import (
urlencode as django_urlencode, urlquote as django_urlquote
)
from django.utils.six.moves import reduce as reduce_function, xmlrpc_client
from django.utils.translation import ugettext_lazy as _
import mayan
from mayan.apps.common.compat import dict_type, dictionary_type
@@ -46,13 +45,6 @@ def encapsulate(function):
return lambda: function
def get_user_label_text(context):
if not context['request'].user.is_authenticated:
return _('Anonymous')
else:
return context['request'].user.get_full_name() or context['request'].user
def introspect_attribute(attribute_name, obj):
"""
Resolve the attribute of model. Supports nested reference using dotted
+2 -24
View File
@@ -19,7 +19,7 @@ from mayan.apps.acls.models import AccessControlList
from .exceptions import NotLatestVersion, UnknownLatestVersion
from .forms import (
LicenseForm, LocaleProfileForm, LocaleProfileForm_view,
PackagesLicensesForm, UserForm, UserForm_view
PackagesLicensesForm
)
from .generics import ( # NOQA
AssignRemoveView, ConfirmView, FormView, MultiFormView,
@@ -66,28 +66,6 @@ class CheckVersionView(SimpleView):
}
class CurrentUserDetailsView(SingleObjectDetailView):
form_class = UserForm_view
def get_object(self):
return self.request.user
def get_extra_context(self, **kwargs):
return {
'object': None,
'title': _('Current user details'),
}
class CurrentUserEditView(SingleObjectEditView):
extra_context = {'object': None, 'title': _('Edit current user details')}
form_class = UserForm
post_action_redirect = reverse_lazy('common:current_user_details')
def get_object(self):
return self.request.user
class CurrentUserLocaleProfileDetailsView(TemplateView):
template_name = 'appearance/generic_form.html'
@@ -190,7 +168,7 @@ class ObjectErrorLogEntryListClearView(ConfirmView):
def view_action(self):
self.get_object().error_logs.all().delete()
messages.success(
message_('Object error log cleared successfully'),
message=_('Object error log cleared successfully'),
request=self.request
)