diff --git a/.gitignore b/.gitignore index 23d2dcc..e8f1c7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ venv *.sqlite3 -*.pyc \ No newline at end of file +*.pyc diff --git a/apps/chats/forms.py b/apps/chats/forms.py index 4d3e923..a6427c1 100644 --- a/apps/chats/forms.py +++ b/apps/chats/forms.py @@ -15,7 +15,8 @@ class Meta: helper = FormHelper() helper.form_method = 'POST' - helper.add_input(Submit('Create', 'Create', css_class='btn-lg btn-primary')) + helper.add_input(Submit( + 'Create', 'Create', css_class='btn-lg btn-primary pull-right')) class EnrollRoomForm(forms.Form): @@ -23,4 +24,5 @@ class EnrollRoomForm(forms.Form): validators=[MinLengthValidator(6), ]) helper = FormHelper() helper.form_method = 'POST' - helper.add_input(Submit('Enroll', 'Enroll', css_class='btn-lg btn-primary')) + helper.add_input(Submit( + 'Enroll', 'Enroll', css_class='btn-lg btn-primary pull-right')) diff --git a/apps/chats/views.py b/apps/chats/views.py index cad1cb8..22c8978 100644 --- a/apps/chats/views.py +++ b/apps/chats/views.py @@ -1,3 +1,5 @@ +import datetime + from django.views.generic import ListView, CreateView, DetailView from django.shortcuts import redirect, get_object_or_404 from django.views.generic.edit import FormMixin @@ -6,7 +8,7 @@ from ..messages.forms import CreateMessageForm from ..messages.models import Message - +from ..users.models import User from .models import ChatRoom from .forms import CreateRoomForm, EnrollRoomForm @@ -49,6 +51,10 @@ def get_context_data(self, **kwargs): context['form'] = self.get_form(self.get_form_class()) context['room'] = get_object_or_404(ChatRoom, slug=self.kwargs['slug']) context['room_messages'] = Message.objects.filter(room=context['room']) + users = User.objects.filter( + last_login__gt=self.request.user.last_logged_out, + is_active__exact=1, ).order_by('-last_login') + context['online_users'] = users return context def post(self, request, *args, **kwargs): @@ -61,7 +67,8 @@ def post(self, request, *args, **kwargs): return self.form_invalid(form) def form_valid(self, form): - form.instance.user = self.request.user + form.instance.created_by = self.request.user + form.instance.created_at = datetime.datetime.now() form.instance.room = get_object_or_404( ChatRoom, slug=self.kwargs['slug']) form.save() diff --git a/apps/messages/forms.py b/apps/messages/forms.py index b8100bb..2f5bd73 100644 --- a/apps/messages/forms.py +++ b/apps/messages/forms.py @@ -16,4 +16,5 @@ class Meta: helper = FormHelper() helper.form_method = 'POST' - helper.add_input(Submit('Post', 'Post', css_class='btn-lg btn-primary')) + helper.add_input(Submit( + 'Send', 'Send', css_class='btn-lg btn-primary pull-right')) diff --git a/apps/messages/models.py b/apps/messages/models.py index 2c34022..dc1f5e6 100644 --- a/apps/messages/models.py +++ b/apps/messages/models.py @@ -8,8 +8,8 @@ class Message(models.Model): created_by = models.ForeignKey(User) room = models.ForeignKey(ChatRoom) created_at = models.DateTimeField(auto_now=False) - body = models.CharField(max_length=140, - help_text='Max characters is 140.') + body = models.CharField(max_length=400, + help_text='Max characters is 400.') def __unicode__(self): return self.body diff --git a/apps/users/forms.py b/apps/users/forms.py index a2eb2f6..d2baa31 100644 --- a/apps/users/forms.py +++ b/apps/users/forms.py @@ -1,6 +1,9 @@ from django import forms from django.contrib.auth.forms import ReadOnlyPasswordHashField +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Submit + from .models import User @@ -45,8 +48,11 @@ class Meta: model = User fields = ('username', 'email') + helper = FormHelper() + helper.form_method = 'POST' + helper.add_input(Submit('Create', 'Create', css_class='btn-lg btn-primary')) + def signup(self, request, user): - email = self.cleaned_data['email'] - user.email = email + user.email = self.cleaned_data['email'] user.username = self.cleaned_data['username'] user.save() diff --git a/apps/users/models.py b/apps/users/models.py index df8d21d..d5fd97f 100644 --- a/apps/users/models.py +++ b/apps/users/models.py @@ -1,5 +1,8 @@ +import datetime + from django.db import models from django.contrib.auth.models import BaseUserManager, AbstractBaseUser +from django.contrib.auth.signals import user_logged_out class MyUserManager(BaseUserManager): @@ -32,6 +35,7 @@ class User(AbstractBaseUser): username = models.CharField(max_length=30, unique=True) is_admin = models.BooleanField(default=False) is_active = models.BooleanField(default=True) + last_logged_out = models.DateTimeField(auto_now=True) objects = MyUserManager() @@ -56,3 +60,9 @@ def has_module_perms(self, app_label): @property def is_staff(self): return self.is_admin + + +def update_logged_out(sender, user, request, **kwargs): + user.last_logged_out = datetime.datetime.now() + +user_logged_out.connect(update_logged_out) diff --git a/chatrooms/settings.py b/chatrooms/settings.py index ea1b794..6d38b13 100644 --- a/chatrooms/settings.py +++ b/chatrooms/settings.py @@ -137,3 +137,5 @@ ) CRISPY_TEMPLATE_PACK = 'bootstrap3' + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/chatrooms/urls.py b/chatrooms/urls.py index d39723c..1d3c7a8 100644 --- a/chatrooms/urls.py +++ b/chatrooms/urls.py @@ -1,10 +1,19 @@ from django.conf.urls import patterns, include, url +from django.views.generic import TemplateView from django.contrib import admin admin.autodiscover() urlpatterns = patterns( '', + url(r'^$', + TemplateView.as_view(template_name='static/index.html'), + name='home'), + + url(r'^about/$', + TemplateView.as_view(template_name='static/about.html'), + name='about'), + url(r'^admin/', include(admin.site.urls)), url(r'^accounts/', include('allauth.urls')), url(r'^accounts/', include('apps.users.urls', namespace="users")), diff --git a/static/css/app.css b/static/css/app.css index 5f69d63..d0f8cc0 100644 --- a/static/css/app.css +++ b/static/css/app.css @@ -5,6 +5,41 @@ position: relative; } .message { + font-size: 16px; } -p { +#get-started { + background: url('../img/ocean.jpg') no-repeat; + background-size: cover; + display: block; + height: 93vh; + max-height: 93vh; +} +#greeting { + padding: 15px; + background-color: rgba(255, 255, 255, 0.6); + margin-top: 25vh; +} +.navbar { + margin-bottom: 0; +} +.btn-transparent { + padding: 11px 17px; + font-size: 20px; + letter-spacing: 0.15em; + color: #999; + background-color: rgba(255, 255, 255, 0); + border-color: #999; + transition: all 0.6s ease; + -webkit-transition: all 0.6s ease; + -moz-transition: all 0.6s ease; + -o-transition: all 0.6s ease; +} +.btn-transparent:hover, .btn-transparent:focus { + color: #fff; + background-color: #428bca; + border-color: #fff; +} +ul { + list-style-type: none; + padding-left: 0; } \ No newline at end of file diff --git a/static/img/ocean.jpg b/static/img/ocean.jpg new file mode 100644 index 0000000..9d9c5ae Binary files /dev/null and b/static/img/ocean.jpg differ diff --git a/templates/account/account_inactive.html b/templates/account/account_inactive.html new file mode 100755 index 0000000..3347f4f --- /dev/null +++ b/templates/account/account_inactive.html @@ -0,0 +1,11 @@ +{% extends "account/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Account Inactive" %}{% endblock %} + +{% block content %} +
{% trans "This account is inactive." %}
+{% endblock %} diff --git a/templates/account/base.html b/templates/account/base.html new file mode 100755 index 0000000..3070348 --- /dev/null +++ b/templates/account/base.html @@ -0,0 +1,3 @@ +{% extends "base.html" %} + + diff --git a/templates/account/email.html b/templates/account/email.html new file mode 100755 index 0000000..f0a6fbc --- /dev/null +++ b/templates/account/email.html @@ -0,0 +1,88 @@ +{% extends "account/base.html" %} +{% load i18n %} +{% load url from future %} +{% block title %}{% trans "Email" %}{% endblock %} + +{% block content %} + {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %} +{% trans 'Estas direcciones de email están asociadas a tu cuenta:' %}
+ + ++ {% trans 'Warning:'%}{% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}
+ + {% endif %} + + +{% blocktrans with confirmation.email_address.email as email %}Please confirm that {{ email }} is an e-mail address for user {{ user_display }}.{% endblocktrans %}
+ + + +{% else %} + +{% url 'account_email' as email_url %} + +{% blocktrans %}This e-mail confirmation link expired or is invalid. Please issue a new e-mail confirmation request.{% endblocktrans %}
+ +{% endif %} + +{% endblock %} diff --git a/templates/account/email_confirmed.html b/templates/account/email_confirmed.html new file mode 100755 index 0000000..bd498d3 --- /dev/null +++ b/templates/account/email_confirmed.html @@ -0,0 +1,17 @@ +{% extends "account/base.html" %} + +{% load i18n %} +{% load account %} + +{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %} + + +{% block content %} + +{% blocktrans with email_address.email as email %}You have confirmed that {{ email }} is an e-mail address for user {{ user_display }}.{% endblocktrans %}
+ +{% endblock %} diff --git a/templates/account/login.html b/templates/account/login.html new file mode 100644 index 0000000..3073296 --- /dev/null +++ b/templates/account/login.html @@ -0,0 +1,49 @@ +{% extends "base.html" %} {% block title %} Chatrooms | Login {% endblock %} {% block content %} +{% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %}
+ + +{% blocktrans %}Feel free to comunicate with me if you have any problems creating your new password.{% endblocktrans %}
+{% blocktrans %}Reset account password email sent. Please contact me if you don't receive the email shortly.{% endblocktrans %}
+The link to create a new password is invalid, it is possible that it has been used. You can resend the email here.
+ {% else %} + {% if form %} +{% trans 'Your password has already been changed.' %}
+ {% endif %} + {% endif %} +{% trans 'Your new password has been set. Now you may ' %} login {% trans ' with your new password.' %}
+{% trans "We are sorry, but the sign up is currently closed." %}
+{% endblock %} + + diff --git a/templates/account/snippets/already_logged_in.html b/templates/account/snippets/already_logged_in.html new file mode 100755 index 0000000..00799f0 --- /dev/null +++ b/templates/account/snippets/already_logged_in.html @@ -0,0 +1,5 @@ +{% load i18n %} +{% load account %} + +{% user_display user as user_display %} +{% trans "Note" %}: {% blocktrans %}you are already logged in as {{ user_display }}.{% endblocktrans %}
diff --git a/templates/account/verification_sent.html b/templates/account/verification_sent.html new file mode 100755 index 0000000..2389cf6 --- /dev/null +++ b/templates/account/verification_sent.html @@ -0,0 +1,25 @@ +{% extends "account/base.html" %} +{% block title %} Verificación Enviada| Notaso {% endblock %} +{% block header %} +{% blocktrans %}Hemos enviado un e-mail para la verificación. Entre al ensalace provisto en el e-mail para finalizar el proceso de registracion. Favor contactenos si no recibe el e-mail en los proximos minutos.{% endblocktrans %}
+ +{% blocktrans %}This part of the site requires us to verify that +you are who you claim to be. For this purpose, we require that you +verify ownership of your e-mail address. {% endblocktrans %}
+ +{% blocktrans %}We have sent an e-mail to you for +verification. Please click on the link inside this e-mail. Please +contact us if you do not receive it within a few minutes.{% endblocktrans %}
+ +{% blocktrans %}Note: you can still change your e-mail address.{% endblocktrans %}
+ + +{% endblock %} + +{% block title %} Verificación Enviada| Notaso {% endblock %} +{% block header %} +{% blocktrans %}Esta parte de la página nos requiere que verifiquemos que eres quien dices ser. Por esta razón, pedimos verificar que usted es el dueño de la cuenta de e-mail que nos fue provista.{% endblocktrans %}
+ +{% blocktrans %}Hemos enviado un e-mail para la verificación. Entre al enlace provisto en el e-mail para finalizar el proceso de registro. Favor contactenos si no recibe el e-mail en los proximos minutos.{% endblocktrans %}
+ +{% blocktrans %}Note: you can still change your e-mail address.{% endblocktrans %}
+ + +{{ room }} - {{ room.members.count }} members
{% endfor %} + + {% else %} +{% trans "An error occurred while attempting to login via your social network account." %}
+{% endblock %} diff --git a/templates/socialaccount/base.html b/templates/socialaccount/base.html new file mode 100755 index 0000000..18530d1 --- /dev/null +++ b/templates/socialaccount/base.html @@ -0,0 +1,2 @@ +{% extends "account/base.html" %} + diff --git a/templates/socialaccount/connections.html b/templates/socialaccount/connections.html new file mode 100755 index 0000000..46ae8c0 --- /dev/null +++ b/templates/socialaccount/connections.html @@ -0,0 +1,77 @@ +{% extends "socialaccount/base.html" %} + +{% block header %} +{% blocktrans %}Puedes hacer login usando cualquiera de las siguientes cuentas:{% endblocktrans %}
+ + + + +{% else %} +{% trans 'Al momento, no tiene ningun perfil social conectado a esta cuenta.' %}
+{% endif %} +{% blocktrans %}You decided to cancel logging in to our site using one of your existing accounts. If this was a mistake, please proceed to sign in.{% endblocktrans %}
+ +{% endblock %} + diff --git a/templates/socialaccount/messages/account_connected.txt b/templates/socialaccount/messages/account_connected.txt new file mode 100755 index 0000000..be6aa60 --- /dev/null +++ b/templates/socialaccount/messages/account_connected.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}The social account has been connected.{% endblocktrans %} diff --git a/templates/socialaccount/messages/account_connected_other.txt b/templates/socialaccount/messages/account_connected_other.txt new file mode 100755 index 0000000..e90f6cc --- /dev/null +++ b/templates/socialaccount/messages/account_connected_other.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}The social account is already connected to a different account.{% endblocktrans %} diff --git a/templates/socialaccount/messages/account_disconnected.txt b/templates/socialaccount/messages/account_disconnected.txt new file mode 100755 index 0000000..fd43f30 --- /dev/null +++ b/templates/socialaccount/messages/account_disconnected.txt @@ -0,0 +1,2 @@ +{% load i18n %} +{% blocktrans %}The social account has been disconnected.{% endblocktrans %} diff --git a/templates/socialaccount/signup.html b/templates/socialaccount/signup.html new file mode 100755 index 0000000..413aa66 --- /dev/null +++ b/templates/socialaccount/signup.html @@ -0,0 +1,67 @@ +{% extends "socialaccount/base.html" %} +{% block title %}Sign-up | Notaso{% endblock %} +{% block header %} +Conoces a tus profesores antes de entrar al salón
+¿Tiene una cuenta? Puedes accederla aquí.
+{% blocktrans with provider_name=account.get_provider.name site_name=site.name %}Vas a usar tu cuenta de {{provider_name}} para acceder a {{site_name}}. Como paso final, favor complete la siguiente informacion:{% endblocktrans %}
+If you have any issue and/or recomendation. Feel free to let us know at the projects issue page on Github.
+{{ room }} - {{ room.members.count }} members
+ {% endfor %} + {% else %} +