Skip to content

Commit

Permalink
Merge pull request EGCETSII#30 from Decide-Part-Rota/Rota3-008
Browse files Browse the repository at this point in the history
Rota3 008- tarea añadir perfil
  • Loading branch information
Abrcobgal authored Dec 16, 2022
2 parents 4f31690 + d6ad449 commit 610164e
Show file tree
Hide file tree
Showing 65 changed files with 3,038 additions and 50 deletions.
12 changes: 12 additions & 0 deletions .CommitsTemplate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<type>: <description>

[optional body]

(Important this is template to be erase before you do a commit. DO NOT FORGET TO ERASE ALL THE INFO IN THIS TEMPLATE!)
Types of <type>:
fix: this commit patches a bug in your codebase
feat: this commit introduces a new feature to the codebase
test: this commit introduces new test for a funtionality in the codebase

<description> An usuful an short summary of the work done in the commit
<body> A more in depth description of the new functionality (optional)
2 changes: 2 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ jobs:
build:

runs-on: ubuntu-latest

env:
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_SECRET: ${{ secrets.GOOGLE_SECRET }}
EMAIL_USER: ${{ secrets.EMAIL_USER }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}


services:
postgres:
image: postgres:10.8
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ coverage.xml
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,5 @@ A tener en cuenta:
* En un servidor local, con un postgres que por defecto nos viene limitado a 100 usuarios
concurrentes, cuando pongamos más de 100, lo normal es que empiecen a fallar muchas peticiones.
* Si hacemos las pruebas en local, donde tenemos activado el modo debug de Django, lo normal es que
las peticiones tarden algo más y consigamos menos RPS (Peticiones por segundo)..
las peticiones tarden algo más y consigamos menos RPS (Peticiones por segundo)

3 changes: 3 additions & 0 deletions decide/.env:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\rafae\Downloads\env.zip
2 changes: 1 addition & 1 deletion decide/authentication/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

sexos=[("mujer","Mujer"),("hombre","Hombre"),("otro","Otro")]
status=[("soltero","Soltero"),("conviviente","Conviviente"),("casado","Casado"),("divorciado","Divorciado"),("viudo","Viudo")]
discord_validator = RegexValidator('[a-zA-Z]#[1-9]{4}')
discord_validator = RegexValidator('.+#\d{4}')

class PersonForm(UserCreationForm):
sex = forms.ChoiceField(choices=sexos, required=True, label="Seleccione su sexo")
Expand Down
53 changes: 53 additions & 0 deletions decide/authentication/static/registration/header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
* {
margin: 0;
padding: 0;
}

body {
background: #fffffa;
}

header {
width: 100%;
overflow: hidden;
background: #252932;
margin-bottom: 20px;
}

.wrapper {
width: 90%;
max-width: 1000px;
margin: auto;
overflow: hidden;
}

header .logo {
color: #f2f2f2;
font-size: 50px;
line-height: 200px;
float: left;
}

header nav {
float: right;
line-height: 200px;
}

header nav a {
display: inline-block;
color: #fff;
text-decoration: none;
padding: 10px 20px;
line-height: normal;
font-size: 20px;
font-weight: bold;
-webkit-transition: all 500ms ease;
-o-transition: all 500ms ease;
transition: all 500ms ease;
border-radius: 50px;
}

header nav a:hover {
background: blue;
border-radius: 50px;
}
25 changes: 25 additions & 0 deletions decide/authentication/templates/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>
<body>

<h2>Profile</h2>

<form method="POST", action="/authentication/editProfile/">
{%csrf_token%}
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="{{first_name}}" readonly><br><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="{{last_name}}" readonly><br><br>
<label for="email">Email:</label><br>
<input type="text" id="email" name="email" value="{{email}}" readonly><br><br>
<label for="age">Age:</label><br>
<input type="text" id="age" name="age" value="{{age}}" readonly><br><br>
<label for="discord_account">Discord account:</label><br>
<input type="text" id="discord_account" name="discord_account" value="{{discord_account}}" pattern = ".+#\d{4}"><br><br>
<small id="helpText" class="form-text text-muted">Remember pattern: name#XXXX</small><br><br><br>

<input type="submit" value="Edit discord account">
</form>


</body>
</html>
52 changes: 28 additions & 24 deletions decide/authentication/templates/welcome.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
{% extends "base.html" %}
{% load i18n static %}

{% block extrahead %}
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css" />

<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css" />
<title>Welcome</title>
{% endblock %}

{% block content %}
<!-- Navbar -->
<div >

<h2>¡Bienvenido, {{user.first_name}}!</h2>


<a href="{% url 'salir'%}">Cerrar sesion</a>

{% if message %}
<p>Error: {{message}}</p>
{% endif %}
</div>
{% endblock %}
{% load static %}
<html lang="es-ES">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inicio</title>
<link rel="stylesheet" href="{% static 'registration/header.css' %}">
</head>
<body>
<header>
<div class="wrapper">

<div class="logo">Decide</div>

<nav>
<a href="authentication/profile/">Perfil</a>
<a href="#">Censo</a>
<a href="#">Mis votaciones</a>
<a href="{% url 'salir'%}">Cerrar sesión</a>
</nav>
</div>
</header>

<h2>¡Bienvenido, {{user.username}}!</h2>

</body>
</html>
6 changes: 4 additions & 2 deletions decide/authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rest_framework.authtoken.views import obtain_auth_token


from .views import GetUserView, LogoutView, RegisterView, loginForm, register, salir, loginForm, complete, anonymous
from .views import GetUserView, LogoutView, RegisterView, loginForm, register, salir, loginForm, complete, anonymous, profileView, editProfile

from django.contrib import admin
from django.views.generic import TemplateView
Expand All @@ -18,7 +18,9 @@
path('accounts/', include('django.contrib.auth.urls')),
path('salir/', salir, name='salir'),
path('completeForm/', complete),
path('anonymous/', anonymous)
path('anonymous/', anonymous),
path('profile/', profileView),
path('editProfile/', editProfile)



Expand Down
14 changes: 14 additions & 0 deletions decide/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,17 @@ def complete(request):
else:
return redirect('/')

def profileView(request):
user = request.user
person = Person.objects.get(user = user.id)
context = {'username': user.username, 'email': user.email, 'first_name': user.first_name, 'last_name': user.last_name, 'sex': person.sex,
'discord_account': person.discord_account, 'age': person.age}
return render(request, 'profile.html', context)

def editProfile(request):
user = request.user
new_disc_account = request.POST['discord_account']
person = Person.objects.get(user = User.objects.get(id=request.user.id))
person.discord_account = new_disc_account
person.save()
return redirect('/authentication/profile/')
2 changes: 1 addition & 1 deletion decide/booth/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.contrib import admin


# Register your models here.
2 changes: 1 addition & 1 deletion decide/booth/templates/booth/booth.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h2>[[ voting.question.desc ]]</h2>
<script src="{% static "crypto/elgamal.js" %}"></script>

<!-- Vuejs -->
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue@2.7.10"></script>
<script src="https://unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>

Expand Down
4 changes: 4 additions & 0 deletions decide/census/export/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Export Folder
================================

Este directorio incluirá todos los censos que exportes.
2 changes: 2 additions & 0 deletions decide/census/export/export_pruebaDiscord.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
username,first_name,last_name,email
practica,,,[email protected]
16 changes: 16 additions & 0 deletions decide/census/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
div.title {
margin-top: 2%
}

div.submit {
margin-top: 2%;
}

.row {
margin-top: 1%;
margin-bottom: 1%;
}

.group-button {
margin-left: 25px;
}
82 changes: 82 additions & 0 deletions decide/census/templates/census_add.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{% extends "base.html" %}
{% load i18n static %}

{% block extrahead %}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>

<link type="text/css" rel="stylesheet" href="{% static 'style.css' %}" />
{% endblock %}


{% block content %}
<div class="title">
<h2>{% trans "Manage Census" %}</h2>
</div>

<div class="row justify-content-md-center">
<div class="col-sm-8">
<h4>{% trans "In this view you can manage the census by adding a user to a specific voting" %}</h4>
</div>
</div>

<div class="row">

</div>

<form class="row gx-3 gy-2 align-items-center" action="add_to_census" method="POST">
{% csrf_token %}
<div class="row justify-content-md-center">
<div class="col-sm-8">
<label for="voting-select">{% trans "Choose a voting" %}</label>
<select class="form-select" id="voting-select" name="voting-select">
{% for voting in votings %}
<option value="{{voting.id}}">{{voting}}</option>
{%endfor%}
</select>

</div>
</div>
<div class="row justify-content-md-center">
<div class="col-sm-8">
<label for="user-select">{% trans "Choose a user" %}</label>
<select class="form-select" id="user-select" name="user-select">
{% for user in users %}
<option value="{{user.id}}">{{user}}</option>
{%endfor%}
</select>
</div>
</div>
<div class="row justify-content-center submit">
<div class="col col-lg-1">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>

<div class="row justify-content-center submit">
<div class="col col-lg-2">
<a href="by_group"><button type="button" class="btn btn-primary group-button">{% trans "Or Add By Group" %}</button></a>
</div>
</div>

{% if messages %}
<ul class="messages" style="margin-top:2%">
{% for message in messages %}
{% if message.tags == 'error' %}
<li class="{{ message.tags }} alert alert-danger" role="alert">{{ message }}</li>
{% else %}
<li class="{{ message.tags }} alert alert-{{message.tags}}" role="alert">{{ message }}</li>
{% endif %}

{% endfor %}
</ul>

{% endif %}



{% include 'footer.html' %}


{% endblock %}
Loading

0 comments on commit 610164e

Please sign in to comment.