Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
janno42 committed Jan 2, 2024
2 parents d64ece3 + 75bee41 commit b1a1590
Show file tree
Hide file tree
Showing 110 changed files with 3,580 additions and 1,837 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Since text files will be used in a linux environment where LF is expected, git shouldn't change line endings to CRLF on windows machines
* text=auto eol=lf

# things that fail without this:
# * bash autocompletion (.sh): -bash: /etc/bash_completion.d/manage_autocompletion.sh: line 8: syntax error near unexpected token `$'\r''
# * running python files: /usr/bin/env: ‘python3\r’: No such file or directory
# Since that's a huge part of the code base, it doesn't really make sense to allow automatic EOL conversion for the rest of the files.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "evap/static/bootstrap"]
path = evap/static/bootstrap
url = https://github.com/twbs/bootstrap.git
shallow = true
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,31 @@ EvaP is the course evaluation system used internally at Hasso Plattner Institute
For the documentation, please see our [wiki](https://github.com/e-valuation/EvaP/wiki).


## Installation
## Installation (for Development)

The easiest setup using [Vagrant](https://www.vagrantup.com) is shown here.

0. Install [git](https://git-scm.com/downloads), [Vagrant](https://www.vagrantup.com/downloads.html), and one of [VirtualBox](https://www.virtualbox.org/wiki/Downloads) (recommended) or [Docker](https://docs.docker.com/engine/install/) (for ARM systems).
1. Install [git](https://git-scm.com/downloads), [Vagrant](https://www.vagrantup.com/downloads.html), and one of [VirtualBox](https://www.virtualbox.org/wiki/Downloads) (recommended) or [Docker](https://docs.docker.com/engine/install/) (for ARM systems).

1. Fork the EvaP repository (using the Fork-button in the upper right corner on GitHub).
2. Run the following commands on the command line to clone the repository, create the Vagrant VM and run the Django development server.
* If you are familiar with the fork-based open source workflow, create a fork and clone that (using SSH if you prefer that).

2. Windows users only (might not apply for the Linux subsystem):
* Line endings: git's [`core.autocrlf` setting](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf) has to be `false` or `input` so git does not convert line endings on checkout, because the code will be used in a Linux VM. We suggest using this command in Git Bash:
* Windows users: We have observed [weird](https://www.github.com/git-for-windows/git/issues/4705) [behavior](https://www.github.com/git-for-windows/git/issues/4704) with SSH in Git Bash on Windows and thus recommend using PowerShell instead.

```bash
git config --global core.autocrlf input
```
* To use Docker, replace `vagrant up` with `vagrant up --provider docker && vagrant provision`.

3. Run the following commands on the command line to clone the repository, create the Vagrant VM and run the Django development server.
To use Docker, replace `vagrant up` with `vagrant up --provider docker && vagrant provision`.
```bash
git clone --recurse-submodules https://github.com/<your_github_username>/EvaP.git
git clone --recurse-submodules https://github.com/e-valuation/EvaP.git
cd EvaP
vagrant up
vagrant ssh
```
and, after the last command opened an SSH session in the development machine:
```bash
./manage.py run
```

4. Open your browser at http://localhost:8000/ and login with email `[email protected]` and password `evap`.

3. Open your browser at http://localhost:8000/ and login with email `[email protected]` and password `evap`.

That's it!
Expand All @@ -55,6 +53,22 @@ or, to combine all three, simply run `./manage.py precommit`.

You can also set up `pylint`, `isort`, `black` and `prettier` in your IDE to avoid doing this manually all the time.

### Creating a Pull Request (Workflow Suggestion)
1. (once) [Fork](https://github.com/e-valuation/EvaP/fork) the repository so you have a GitHub repo that you have write access to.

2. (once) Set up some authentication for GitHub that allows push access. A common option is using [SSH keys](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh), the remaining instructions assume an SSH key setup. An alternative is using the [GitHub CLI tool](https://cli.github.com/).

3. (once) Ensure your [git remotes](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) are setup to use SSH. To fetch the up-to-date state of the official repo, it's useful to have an "upstream" remote configured:
```bash
git remote set-url origin [email protected]:<your-username>/EvaP.git
git remote add upstream [email protected]:e-valuation/EvaP.git
```
4. Create a branch (`git switch -c <your-branch-name>`), commit your changes (`git add` and `git commit`), and push them (`git push`). "Push" will ask you to specify an upstream branch (`git push -u origin <your-branch-name>`).
5. GitHub should now ask you whether you want to open a pull request ("PR"). If the PR solves an issue, use one of GitHub's [magic keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) (like "fixes") in the pull request description to create a link between your PR and the issue. If necessary, please also provide a short summary of your changes in the description.


## License

MIT, see [LICENSE.md](LICENSE.md).
Expand Down
6 changes: 6 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Vagrant.configure("2") do |config|
end
end

if Vagrant::Util::Platform.windows? then
# workaround for git bash not automatically allocating a tty on windows in some scenarios
# see https://github.com/hashicorp/vagrant/issues/9143#issuecomment-401088752
config.ssh.extra_args = "-tt"
end

config.vm.provider :docker do |d, override|
d.image = "ubuntu:jammy"
# Docker container really are supposed to be used differently. Hacky way to make it into a "VM".
Expand Down
8 changes: 8 additions & 0 deletions evap/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from django.conf import settings
from django.utils.translation import get_language

from evap.evaluation.forms import NotebookForm


def slogan(request):
if get_language() == "de":
Expand All @@ -14,5 +16,11 @@ def debug(request):
return {"debug": settings.DEBUG}


def notebook_form(request):
if request.user.is_authenticated:
return {"notebook_form": NotebookForm(instance=request.user)}
return {}


def allow_anonymous_feedback_messages(request):
return {"allow_anonymous_feedback_messages": settings.ALLOW_ANONYMOUS_FEEDBACK_MESSAGES}
10 changes: 8 additions & 2 deletions evap/contributor/templates/contributor_evaluation_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,14 @@ <h5 class="modal-title" id="previewModalLabel">{% trans 'Preview' %}</h5>
{% include 'confirmation_modal.html' with modal_id='approveEvaluationModal' title=title question=question action_text=action_text btn_type='primary' %}
<script type="text/javascript">
function approveEvaluationModalAction(dataId) {
$('#evaluation-form').append('<input type="hidden" name="operation" value="approve" />');
$('#evaluation-form').submit();
const input = document.createElement("input");
input.type = "hidden";
input.name = "operation";
input.value = "approve";

const form = document.getElementById("evaluation-form");
form.appendChild(input);
form.requestSubmit();
};
</script>

Expand Down
7 changes: 4 additions & 3 deletions evap/contributor/templates/contributor_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,15 @@ <h5 class="modal-title" id="{{ modal_id }}Label">{% trans 'Delegate preparation'

<script type="text/javascript">
function {{ modal_id }}Show(evaluationName, action) {
const modal = document.getElementById("{{ modal_id }}");
// set form's action location
$('#{{ modal_id }} form').attr('action', action);
modal.querySelectorAll("form").forEach(form => form.action = action);

// put the correct evaluation name in the modal
$('#{{ modal_id }} [data-label=""]').text(evaluationName);
modal.querySelectorAll('[data-label=""]').forEach(el => el.innerText = evaluationName);

// unselect any previously selected options in the modal
$('#{{ modal_id }} select').val(null).trigger('change');
modal.querySelectorAll("select").forEach(select => select.tomselect.clear());

// show modal
var {{ modal_id }} = new bootstrap.Modal(document.getElementById('{{ modal_id }}'));
Expand Down
16 changes: 16 additions & 0 deletions evap/contributor/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import xlrd
from django.core import mail
from django.urls import reverse
from django_webtest import WebTest
from model_bakery import baker

Expand Down Expand Up @@ -284,3 +286,17 @@ def test_display_request_buttons(self):
page = self.app.get(self.url, user=self.responsible)
self.assertEqual(page.body.decode().count("Request changes"), 0)
self.assertEqual(page.body.decode().count("Request creation of new account"), 2)


class TestContributorResultsExportView(WebTest):
@classmethod
def setUpTestData(cls):
result = create_evaluation_with_responsible_and_editor()
cls.url = reverse("contributor:export")
cls.user = result["responsible"]

def test_concise_header(self):
response = self.app.get(self.url, user=self.user)

workbook = xlrd.open_workbook(file_contents=response.content)
self.assertEqual(workbook.sheets()[0].row_values(0)[0], f"Evaluation\n{self.user.full_name}")
1 change: 1 addition & 0 deletions evap/contributor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def export_contributor_results(contributor):
include_not_enough_voters=True,
include_unpublished=False,
contributor=contributor,
verbose_heading=False,
)
return response

Expand Down
Loading

0 comments on commit b1a1590

Please sign in to comment.