Move current user views and add user events
Move the current user detail and edit views from the common app to the user_management app. Add the user created and edited events. Add an user detail view. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -25,11 +25,9 @@ from .handlers import (
|
||||
)
|
||||
from .licenses import * # NOQA
|
||||
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_system, separator_user_label,
|
||||
text_user_label
|
||||
link_setup, link_tools, separator_system
|
||||
)
|
||||
from .literals import DELETE_STALE_UPLOADS_INTERVAL, MESSAGE_SQLITE_WARNING
|
||||
from .menus import (
|
||||
@@ -132,10 +130,8 @@ class CommonApp(MayanAppConfig):
|
||||
)
|
||||
menu_user.bind_links(
|
||||
links=(
|
||||
text_user_label, separator_user_label,
|
||||
link_current_user_details, link_current_user_edit,
|
||||
link_current_user_locale_profile_edit,
|
||||
)
|
||||
), position=50
|
||||
)
|
||||
|
||||
menu_about.bind_links(
|
||||
|
||||
@@ -159,24 +159,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()
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
|
||||
@@ -7,14 +7,12 @@ 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, 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):
|
||||
@@ -42,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'),
|
||||
@@ -101,5 +91,3 @@ link_tools = Link(
|
||||
icon_class=icon_tools, text=_('Tools'), view='common:tools_list'
|
||||
)
|
||||
separator_system = Separator()
|
||||
separator_user_label = Separator()
|
||||
text_user_label = Text(text=get_user_label_text)
|
||||
|
||||
@@ -5,10 +5,9 @@ from django.views.i18n import javascript_catalog, set_language
|
||||
|
||||
from .api_views import APIContentTypeList, APITemplateView
|
||||
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
|
||||
)
|
||||
@@ -32,14 +31,6 @@ urlpatterns = [
|
||||
),
|
||||
url(r'^setup/$', SetupListView.as_view(), name='setup_list'),
|
||||
url(r'^tools/$', ToolsListView.as_view(), name='tools_list'),
|
||||
url(
|
||||
r'^user/$', CurrentUserDetailsView.as_view(),
|
||||
name='current_user_details'
|
||||
),
|
||||
url(
|
||||
r'^user/edit/$', CurrentUserEditView.as_view(),
|
||||
name='current_user_edit'
|
||||
),
|
||||
url(
|
||||
r'^user/locale/$', CurrentUserLocaleProfileDetailsView.as_view(),
|
||||
name='current_user_locale_profile_details'
|
||||
|
||||
@@ -68,13 +68,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 fs_cleanup(filename, file_descriptor=None, suppress_exceptions=True):
|
||||
"""
|
||||
Tries to remove the given filename. Ignores non-existent files
|
||||
|
||||
@@ -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,
|
||||
@@ -65,28 +65,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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user