%global http_dashboard_dir %{_datarootdir}/openstack-dashboard

Name:           openstack-horizon
Version:        18.6.1
Release:        3
Summary:        OpenStack Dashboard (Horizon)
License:        ASL 2.0
Group:          Development/Languages/Python
URL:            https://wiki.openstack.org/OpenStackDashboard
Source0:        horizon-18.6.1.tar.gz
Source1:        openstack-dashboard.conf
# https://review.openstack.org/#/c/635159/
Patch0:         0001-Do-not-set-COMPRESS_ENABLED-explicitly.patch
BuildRequires:  fdupes
BuildRequires:  gettext
BuildRequires:  openstack-macros
BuildRequires:  python3-Django
BuildRequires:  python3-pint
BuildRequires:  python3-XStatic
BuildRequires:  python3-XStatic-Angular
BuildRequires:  python3-XStatic-Angular-Bootstrap
BuildRequires:  python3-XStatic-Angular-FileUpload
BuildRequires:  python3-XStatic-Angular-Gettext
BuildRequires:  python3-XStatic-Angular-Schema-Form
BuildRequires:  python3-XStatic-Angular-lrdragndrop
BuildRequires:  python3-XStatic-Bootstrap-Datepicker
BuildRequires:  python3-XStatic-Bootstrap-SCSS
BuildRequires:  python3-XStatic-D3
BuildRequires:  python3-XStatic-Font-Awesome
BuildRequires:  python3-XStatic-Hogan
BuildRequires:  python3-XStatic-JQuery-Migrate
BuildRequires:  python3-XStatic-JQuery-TableSorter
BuildRequires:  python3-XStatic-JQuery-quicksearch
BuildRequires:  python3-XStatic-JSEncrypt
BuildRequires:  python3-XStatic-Jasmine
BuildRequires:  python3-XStatic-Rickshaw
BuildRequires:  python3-XStatic-Spin
BuildRequires:  python3-XStatic-bootswatch
BuildRequires:  python3-XStatic-jQuery
BuildRequires:  python3-XStatic-jquery-ui
BuildRequires:  python3-XStatic-mdi
BuildRequires:  python3-XStatic-objectpath
BuildRequires:  python3-XStatic-roboto-fontface
BuildRequires:  python3-XStatic-smart-table
BuildRequires:  python3-XStatic-termjs
BuildRequires:  python3-XStatic-tv4
BuildRequires:  python3-cinderclient
BuildRequires:  python3-devel
BuildRequires:  python3-django-compressor
BuildRequires:  python3-django-debreach
BuildRequires:  python3-django-pyscss
BuildRequires:  python3-glanceclient
BuildRequires:  python3-keystoneclient
BuildRequires:  python3-mock
BuildRequires:  python3-netaddr
BuildRequires:  python3-neutronclient
BuildRequires:  python3-novaclient
BuildRequires:  python3-oslo-concurrency
BuildRequires:  python3-oslo-policy
BuildRequires:  python3-osprofiler
BuildRequires:  python3-pbr
BuildRequires:  python3-pytest
BuildRequires:  python3-swiftclient
BuildRequires:  python3-testtools

Requires:       python3-horizon
Requires:       python3-openstack_auth
Requires:       httpd
Requires:       python3-mod_wsgi
Requires(post):  httpd-tools

Provides:       openstack-horizon = %{version}-%{release}
BuildArch:      noarch

%description
The OpenStack dashboard provides administrators and users a graphical
interface to access, provision and automate cloud-based resources. The
extensible design makes it easy to plug in and expose third party
products and services, such as billing, monitoring and additional
management tools.

The dashboard is just one way to interact with OpenStack resources.
Developers can automate access or build tools to manage their resources
using the native OpenStack API or the EC2 compatibility API.

%package -n python3-horizon
Summary:        OpenStack Dashboard (Horizon) - Python Module
Requires:       python3-babel
Requires:       python3-django
Requires:       python3-pint
Requires:       python3-PyYAML
Requires:       python3-XStatic
Requires:       python3-XStatic-Angular
Requires:       python3-XStatic-Angular-Bootstrap
Requires:       python3-XStatic-Angular-FileUpload
Requires:       python3-XStatic-Angular-Gettext
Requires:       python3-XStatic-Angular-Schema-Form
Requires:       python3-XStatic-Angular-lrdragndrop
Requires:       python3-XStatic-Bootstrap-Datepicker
Requires:       python3-XStatic-Bootstrap-SCSS
Requires:       python3-XStatic-D3
Requires:       python3-XStatic-Font-Awesome
Requires:       python3-XStatic-Hogan
Requires:       python3-XStatic-JQuery-Migrate
Requires:       python3-XStatic-JQuery-TableSorter
Requires:       python3-XStatic-JQuery-quicksearch
Requires:       python3-XStatic-JSEncrypt
Requires:       python3-XStatic-Jasmine
Requires:       python3-XStatic-Rickshaw
Requires:       python3-XStatic-Spin
Requires:       python3-XStatic-bootswatch
Requires:       python3-XStatic-jQuery
Requires:       python3-XStatic-jquery-ui
Requires:       python3-XStatic-mdi
Requires:       python3-XStatic-objectpath
Requires:       python3-XStatic-roboto-fontface
Requires:       python3-XStatic-smart-table
Requires:       python3-XStatic-termjs
Requires:       python3-XStatic-tv4
Requires:       python3-cinderclient
Requires:       python3-enmerkar
Requires:       python3-django-compressor
Requires:       python3-django-debreach
Requires:       python3-django-pyscss
Requires:       python3-futurist
Requires:       python3-glanceclient
Requires:       python3-heatclient
Requires:       python3-httplib2
Requires:       python3-iso8601
Requires:       python3-keystoneclient
Requires:       python3-netaddr
Requires:       python3-neutronclient
Requires:       python3-novaclient
Requires:       python3-oslo-concurrency
Requires:       python3-oslo-config
Requires:       python3-oslo-i18n
Requires:       python3-oslo-policy
Requires:       python3-oslo-serialization
Requires:       python3-oslo-utils
Requires:       python3-osprofiler
Requires:       python3-pbr
Requires:       python3-scss
Requires:       python3-pytz
Requires:       python3-semantic_version
Requires:       python3-six
Requires:       python3-swiftclient

%description -n python3-horizon
The Python module horizon is the core component of the OpenStack
dashboard.

%package -n python3-openstack_auth
Summary:        OpenStack Auth (Horizon) - Python Module

%description -n python3-openstack_auth
The Python module OpenStack Auth provides Authentication mechanism
for the OpenStack Dashboard (Horizon).

%prep
%autosetup -p1 -n horizon-18.6.1
%py_req_cleanup

# Fix manage.py python3 support
sed -i 's#%{_bindir}/env python#%{_bindir}/python3#' manage.py

%build
# compile mo files before build
pushd horizon
python3 ../manage.py compilemessages
popd
pushd openstack_dashboard
python3 ../manage.py compilemessages
popd
%{py3_build}

%install
%{py3_install}

# Move openstack_dashboard files
install -d -m 755 %{buildroot}%{http_dashboard_dir}
mv %{buildroot}%{python3_sitelib}/openstack_dashboard/ %{buildroot}%{http_dashboard_dir}
install -m 755 manage.py %{buildroot}%{http_dashboard_dir}/manage.py

# Create a local_settings.py
mv %{buildroot}%{http_dashboard_dir}/openstack_dashboard/local/local_settings.py{.example,}

# create root and static files
install -m 0755 -d %{buildroot}%{http_dashboard_dir}/static
install -m 0755 -d %{buildroot}%{http_dashboard_dir}/media
pushd %{buildroot}%{http_dashboard_dir}
PYTHONPATH=%{buildroot}%{python3_sitelib} python3 manage.py collectstatic --noinput
popd

# cleanup after manage.py run
rm -v %{buildroot}%{http_dashboard_dir}/openstack_dashboard/local/.secret_key_store
rm -v %{buildroot}%{http_dashboard_dir}/openstack_dashboard/local/*secret_key_store*

# Remove duplicate files
rm -f %{buildroot}%{http_dashboard_dir}/openstack_dashboard/.eslintrc

install -D -m 644 %{SOURCE1} %{buildroot}%{apache_conf_dir}/openstack-dashboard.conf

%files
%doc README.rst
%{http_dashboard_dir}
%attr(0755, %{apache_user}, %{apache_group}) %{http_dashboard_dir}/
%{apache_conf_dir}/openstack-dashboard.conf

%files -n python3-horizon
%license LICENSE
%{python3_sitelib}/horizon
%{python3_sitelib}/horizon-*.egg-info

%files -n python3-openstack_auth
%license LICENSE
%{python3_sitelib}/openstack_auth

%changelog
* Thu Feb 25 2021 wangxiyuan <wangxiyuan1007@gmail.com>
- Fix httpd config error

* Sat Feb 20 2021 huangtianhua <huangtianhua223@gmail.com>
- Change to use python-enmerkar instead of django-babel

* Tus Feb 09 2021 wangxiyuan <wangxiyuan1007@gmail.com>
- Init the first openstack victoria release
