ini: drop redundant template update of [handler_console] level=DEBUG
After 05d09cec7b26, the handlers in the default template no longer had a 'level' setting the ini generator could override with DEBUG. We are apparently fine without it, so just remove the last traces.
templates: disable paging and page size controls in DataTables
Since all data is sent to the client side, it can just as well be rendered. PageDown or scrolling is more convenient for paging than paging buttons, so short of "infinite scrolling", showing all entries is an acceptable solution ... especially when it very rarely is hundres of entries.
There could perhaps be further changes to how DataTables is shown - this is one step.
index: show repositories and repository groups in the same table
Having two different tables with their own paging and search gave a bad UI. Instead, do like all other UIs that show directory content and show both "folders" and "files" in the same list.
The rendering of repo groups is changed to use js data instead of a taking data from an html table.
Repository groups are shoe-horned into the repository DataTable. The columns are no perfect match - some of the existing columns are thus given an empty default value.
repogroups: fix display of links to parent repo groups
Links inside panel-primary were shown with the same color as the panel background. Arguably, that's a bug in Bootstrap, but marking it as panel-title fixes that.
pygments: reimplement get_lem under the name get_extension_descriptions
The old implementation was cryptic and over-engineered. And reduce() is not a builtin in Python 3.
This function works on static input, and it was verified that this implementation returns exactly the same as the old one. And is simpler and slightly more readable. In my opinion.
py3: replace list comprehension with for-loop due to scope
The scope of the list comprehension variable 'x' will be limited to the list comprehension in python3. Thus switching to a full loop (without this scope restriction) in preparation for python3.
utils: remove Session after we are done using it in set_app_settings
When the Kallithea WSGI application or celeryd is started, TurboGears app_config.make_base_app calls Kallithea app_cfg.setup_configuration which runs utils.set_app_settings. That function will read settings from the database and store them in the global config. It uses a database session which is created on demand, but this session was not dismissed but left around for the next thing that asked for a database session. MySQL will by default close connections after 1 hour, so when celery tried to run a task after 1 hour of inactivity, it could fail because of the closed connection.
utils.set_app_settings must thus remove the Session after use, just like auth.set_available_permissions do.
This will thus fix for example some MySQL connection problems seen with Celery.
tests: use temporary copy of test.ini, possibly customized for TEST_DB
It was an undocumented feature that if setting the environment variable TEST_DB, that would be used for tests instead of the default kallithea/tests/test.ini sqlalchemy.url . That did however not work for Git hooks and tests would fail.
Instead, create a copy of test.ini in the temp folder and use that for testing. If TEST_DB is set, edit the file so the specified DB URL is used. This fixes Git hook related tests if TEST_DB is used.
Since this also changes the path of %(here)s to the temporary location, just use the default paths.
This also has the advantage that the data folders are now in the temp folder as well. Therefore a broken data folder, from a past run, can no longer influence a test.
templates: tweak file edit page markup to be slightly more correct and make it look slightly better
- use <label> for the commit message label - use .form-group - use form-inline only for the heading - use form-group-sm to make the <select> less bloated
templates: jQuery DataTables need explicit width="100%" for resizing to work correctly
With Firefox, the resizing worked when making the browser window smaller, but not when when making the browser window larger. With Chrome and other browsers, neither worked.
summary: use shared changelog_table implementation on summary page
The main purpose of this change is to simplify code and avoid duplication.
Using the shared implementation also happens to give a slightly different view of the changesets. There will be no table headers, the columns are shown in different order, author gravatars are shown, commit messages can be expanded, and there is slightly different styling.
Small remaining amounts of template code is moved from changelog_summary_data.html to summary.html.
changelog: make the table a re-usable template element
This moves the changelog table to a separate template file, without further changes, except the necessary renaming to make it fully parameterized without accessing c directly.
controllers: consistently use c.cs_comments and cs_statuses
c.comments and c.statuses were also used for lists of comments and statuses. To get more consistency and avoid confusion and conflicts, use different for names for mappings from changeset hashes.
Split commit message into 2 <div> elements: one with just the first line, and one with the full message. This makes it easier to handle the toggling of showing the whole commit message. This way, we no longer have to mess with the line height, and we avoid problems with cutting off parts of the text below the text baseline.
Also stop cutting off the first line if it is too long for the table column.
It adds a bit of overhead to store the first line twice, but having them separate make things simpler and is worth it.
Under some circumstances, the floating of the elements gets altered, if the tooltip elements gets put next to the source element. Therefore use body as the container.
comments: display comment previews while submitting
Instead of just saying 'Submitting' and not showing any progress to the user until the comment has been accepted by the server, show a preview of the comment above the comment box in a way which is makes it obvious to the user the comment is being submitted. Apart from that, also clear the comment box so that a repeated clicking the submit button doesn't result in a duplicate comment.
The preview doesn't highlight URLs or support @mentions or *bold*, which is a good enough approximation in this case. When/if we (re-)add the rST/Markdown support, we will need a client-side parser for the syntax we choose.
When the submission fails, display a message and offer the user to retry or cancel the submission.
changeset range: move gravatar in front of revision link
In the past this was done by setting float:left on the gravatar. This got lost during the partial bootstrap changes. But the html layout should try to reflect the same order as the visual representation. So this now does it in the html code.
templates: more consistently put icons inside 'Delete' and 'Edit' buttons
- on repo, repo group, user and user group list page.
For now, we keep the text and keep the button visible.
The Edit button was typically a submit button, not inside a form but inside an <a>. It did thus not really trigger a submit but just followed the link.
api: change precision of ChangesetStatus.modified_at to seconds
Per default MySQL only uses seconds. So in order to be consistent on all databases, this is the easiest solution. I don't think the microseconds are necessary. And AFAICS mercurial only uses seconds for the changeset modification time as well. So why should we use microseconds for ChangesetStatus.
Without this, for example test_api_get_changeset_with_reviews fails, because of datetime mismatch if MySQL is used.
autocomplete: use select2 when selecting users to add as reviewers to PRs
This is a minimal change to PullRequestAutoComplete, inspired by Dominik Ruf.
The UX is slightly different than before, with select2 putting up an extra input field, already before typing anything.
We use minimumInputLength 1 to get the same behaviour as before and avoid displaying all users in a list.
The select2 widget is reused for adding more users, so when a user is selected, we process it, close the widget, and abort the selection, waiting for the user to enter another user name.
autocomplete: use select2 when selecting owner of repos and PRs
This is a minimal change to SimpleUserAutoComplete, inspired by Dominik Ruf.
The UX is slightly different than before, with select2 putting up an extra input field, already before typing anything.
We use minimumInputLength 1 to get the same behaviour as before and avoid displaying all users in a list. This field will always have an old value and the placeholder is thus never used, but we show it instead of the default "Please enter 1 or more character" message.
The initSelection iteration is not pretty, but no more complex than what happens when filtering the user list, and it has the advantage of giving a nice name/gravatar display of the current user.
celery: replace loader.PylonsSettingsProxy with a simple configuration object
The proxy was quite complex and did all the conversion at runtime, making it hard to figure out exactly what it was doing.
Instead, just create a simple configuration object as described on http://docs.celeryproject.org/en/3.1/userguide/application.html and convert all relevant config settings up front. We don't convert all config settings, but only the ones Celery seems to be interested in. The value conversion heuristics are the same as before and still seem quite fragile.
celery: simplify internal configuration and app creation
We used celery.app.app_or_default() which creates a "global fallback app instance" which relies on the CELERY_LOADER environment variable to load the configuration. That worked but was messy.
Instead, do something more like described in http://docs.celeryproject.org/en/3.1/userguide/application.html where the app is a celery.Celery() instance and configuration is loaded explicitly by its config_from_object method. Using config_from_object we don't need explicit invocation of import_default_modules and can take pass PylonsSettingsProxy directly, leaving PylonsLoader unused and removed.
celeryd: let the gearbox command use db session as most other gearbox commands do
304aae43194c changed the common gearbox wrapper so make_app_without_logging only was run for commands tagged as requires_db_session. That broke celeryd - even a plain 'gearbox celeryd -c my.ini' would fail on the safety check in celerypylons asserting on tg.config having 'celery.imports' configuration.
The gearbox celeryd command did not really require a db session - it just required app configuration so it could create db sessions on the fly.
To to get the missing make_app_without_logging invocation back, set requires_db_session (the default for our gearbox commands).
requires_db_session not only calls make_app_without_logging (which undo the effect from 304aae43194c), it also calls setup_cache_regions, engine_from_config, and init_model. These were also invoked explicitly in celeryd code - these double invocations are dropped too.
Also, make_app_without_logging will call into tg and thus invoke the setup_configuration hook which will set kallithea.CELERY_ON and call load_rcextensions. The celeryd code for doing that is thus dropped.
rcext: this command actually *does* require a config file ... but doesn't require db configuration
'gearbox make-rcext' would fail when trying to do config['here'] without initializing the configuration.
The command would work if we gave it a whole db session, but it is more correct to only require the configuration if that is all it need. The command will however still fail, as the configuration isn't passed on to tg.config .
manifest: update file name list - for example, fix the path to the template.ini.mako config template
The template.ini.mako was renamed in 6c8af2d22deb when the gearbox make-config command was introduced. 'gearbox make-config' in an installed environment would fail without this file.