diff --git a/smash/web/models.py b/smash/web/models.py index 18d09a956d97fec61ebcca4e4013a171499d3c95..66340e5b79ae6c106ec2d2eede7dcd1f63063197 100644 --- a/smash/web/models.py +++ b/smash/web/models.py @@ -113,6 +113,16 @@ class Worker (models.Model): def __str__(self): return self.firstName + " " + self.lastName + @staticmethod + def get_details(the_user): + person = Worker.objects.filter(user=the_user) + if len(person) == 0: + return ('Guest', 'Test account') + else: + # For get_*_display, see: + # https://docs.djangoproject.com/en/1.10/topics/db/models/#field-options + return (str(person[0]), person[0].get_role_display()) + class FlyingTeam(models.Model): doctor = models.ForeignKey(Worker, related_name='FlyingTeamDoctor') diff --git a/smash/web/static/flags/DE.png b/smash/web/static/flags/DE.png new file mode 100644 index 0000000000000000000000000000000000000000..9d35468c0df6666bf09847d80948d698b7c0651b Binary files /dev/null and b/smash/web/static/flags/DE.png differ diff --git a/smash/web/static/flags/FR.png b/smash/web/static/flags/FR.png new file mode 100644 index 0000000000000000000000000000000000000000..ccc9d43715901201d4ccbb8033d27848b4688b67 Binary files /dev/null and b/smash/web/static/flags/FR.png differ diff --git a/smash/web/static/flags/GB.png b/smash/web/static/flags/GB.png new file mode 100644 index 0000000000000000000000000000000000000000..fecad794fa132320c20245bdb4d1eb35bf63b56a Binary files /dev/null and b/smash/web/static/flags/GB.png differ diff --git a/smash/web/static/flags/LU.png b/smash/web/static/flags/LU.png new file mode 100644 index 0000000000000000000000000000000000000000..42c89b6279a2c83ba6a3ef3343a8ef8584bc8f37 Binary files /dev/null and b/smash/web/static/flags/LU.png differ diff --git a/smash/web/static/flags/PT.png b/smash/web/static/flags/PT.png new file mode 100644 index 0000000000000000000000000000000000000000..79c872c38843bf34db9cde14843a87daba385dff Binary files /dev/null and b/smash/web/static/flags/PT.png differ diff --git a/smash/web/static/flags/readme.txt b/smash/web/static/flags/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..250b9059378155743fcc5cf128cf144468975ae4 --- /dev/null +++ b/smash/web/static/flags/readme.txt @@ -0,0 +1,3 @@ +Icons come from an open source project: https://github.com/googlei18n/region-flags +To add another ones, pick them from png folder, and resize to 300x180 to mantain consistency. +Then, add them in administrative panel. diff --git a/smash/web/templates/_base.html b/smash/web/templates/_base.html index 2da89ada2c4e4c1f0e0f93f5002d399f8d9bafb6..761871ec486c39d99658cac0f3a36f0c38848f22 100644 --- a/smash/web/templates/_base.html +++ b/smash/web/templates/_base.html @@ -152,7 +152,7 @@ desired effect <!-- The user image in the navbar--> <img src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image"> {% endcomment %} - <span>Prenom Nom</span> + <span>{{ person }}</span> <i class="fa fa-gears"></i> </a> <ul class="dropdown-menu"> @@ -162,8 +162,8 @@ desired effect <img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image"> {% endcomment %} <p> - Prenom Nom - <small>Secretary</small> + {{ person }} + <small>{{ role }}</small> </p> </li> {% comment "Uncomment if needed %} diff --git a/smash/web/views.py b/smash/web/views.py index 2705c07290495cc6fb46c0eff0bcab6e17a667f8..c310f01a9d7c3475ed9514ca1394ec31268d19f6 100644 --- a/smash/web/views.py +++ b/smash/web/views.py @@ -34,14 +34,17 @@ def login(request): def logout(request): state = do_logout(request) - print state return redirect('/login?error=' + state[1]) def assignments(request): template = loader.get_template("assignments/index.html") + details = Worker.get_details(request.user) + return HttpResponse(template.render({ + 'person' : details[0], + 'role': details[1] }), request)