Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
4a073592
Commit
4a073592
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Plain Diff
Merge branch '365-about-shows-versions-as-unknown' into 'master'
Resolve "[About] Shows versions as "unknown"" Closes
#365
See merge request
!487
parents
11f7d0a4
2c1009a7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!487
Resolve "[About] Shows versions as "unknown""
Pipeline
#5838
passed
4 years ago
Stage: test
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/core/__init__.py
+1
-1
1 addition, 1 deletion
aleksis/core/__init__.py
aleksis/core/apps.py
+1
-0
1 addition, 0 deletions
aleksis/core/apps.py
aleksis/core/util/apps.py
+38
-12
38 additions, 12 deletions
aleksis/core/util/apps.py
with
40 additions
and
13 deletions
aleksis/core/__init__.py
+
1
−
1
View file @
4a073592
...
...
@@ -7,7 +7,7 @@ except ModuleNotFoundError:
celery_app
=
None
try
:
__version__
=
pkg_resources
.
get_distribution
(
"
AlekSIS
"
).
version
__version__
=
pkg_resources
.
get_distribution
(
"
AlekSIS
-Core
"
).
version
except
Exception
:
__version__
=
"
unknown
"
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/apps.py
+
1
−
0
View file @
4a073592
...
...
@@ -21,6 +21,7 @@ from .util.sass_helpers import clean_scss
class
CoreConfig
(
AppConfig
):
name
=
"
aleksis.core
"
verbose_name
=
"
AlekSIS — The Free School Information System
"
dist_name
=
"
AlekSIS-Core
"
urls
=
{
"
Repository
"
:
"
https://edugit.org/AlekSIS/official/AlekSIS/
"
,
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/util/apps.py
+
38
−
12
View file @
4a073592
...
...
@@ -5,6 +5,7 @@ from django.contrib.auth.signals import user_logged_in, user_logged_out
from
django.db.models.signals
import
post_migrate
,
pre_migrate
from
django.http
import
HttpRequest
import
pkg_resources
from
dynamic_preferences.signals
import
preference_updated
from
license_expression
import
Licensing
from
spdx_license_list
import
LICENSES
...
...
@@ -28,21 +29,46 @@ class AppConfig(django.apps.AppConfig):
# Getting an app ready means it should look at its config once
self
.
preference_updated
(
self
)
@classmethod
def
get_name
(
cls
):
def
get_distribution_name
(
self
):
"""
Get pkg_resources distribution name of application package.
"""
if
hasattr
(
self
,
"
dist_name
"
):
return
self
.
dist_name
elif
self
.
name
.
lower
().
startswith
(
"
aleksis.apps.
"
):
return
self
.
name
.
lower
().
replace
(
"
aleksis.apps.
"
,
"
AlekSIS-App-
"
)
return
None
def
get_distribution
(
self
):
"""
Get pkg_resources distribution of application package.
"""
dist_name
=
self
.
get_distribution_name
()
if
dist_name
:
try
:
dist
=
pkg_resources
.
get_distribution
(
dist_name
)
except
pkg_resources
.
DistributionNotFound
:
return
None
return
dist
def
get_name
(
self
):
"""
Get name of application package.
"""
return
getattr
(
cls
,
"
verbose_name
"
,
cls
.
name
)
# TODO Try getting from distribution if not set
if
hasattr
(
self
,
"
verbose_name
"
):
return
self
.
verbose_name
else
:
dist_name
=
self
.
get_distribution_name
()
if
dist_name
:
return
dist_name
return
self
.
name
@classmethod
def
get_version
(
cls
):
def
get_version
(
self
):
"""
Get version of application package.
"""
try
:
from
..
import
__version__
# noqa
except
ImportError
:
__version__
=
None
return
getattr
(
cls
,
"
version
"
,
__version__
)
if
hasattr
(
self
,
"
version
"
):
return
self
.
version
else
:
dist
=
self
.
get_distribution
()
if
dist
:
return
dist
.
version
else
:
return
"
unknown
"
@classmethod
def
get_licence
(
cls
)
->
Tuple
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment