Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
While this is at the moment tied to the gym module, it is possible to use this in the future e.g. in groups.
- Loading branch information
1 parent
f03b971
commit 0003ff3
Showing
19 changed files
with
588 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of wger Workout Manager. | ||
# | ||
# wger Workout Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# wger Workout Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from wger import get_version | ||
|
||
VERSION = get_version() | ||
default_app_config = 'wger.email.apps.Config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of wger Workout Manager. | ||
# | ||
# wger Workout Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# wger Workout Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class Config(AppConfig): | ||
name = 'wger.email' | ||
verbose_name = "Email" | ||
|
||
def ready(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of wger Workout Manager. | ||
# | ||
# wger Workout Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# wger Workout Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
|
||
|
||
from django.utils.translation import ( | ||
pgettext, | ||
ugettext_lazy as _ | ||
) | ||
from django.forms import ( | ||
Form, | ||
CharField, | ||
Textarea | ||
) | ||
|
||
|
||
class EmailListForm(Form): | ||
''' | ||
Small form to send emails | ||
''' | ||
|
||
subject = CharField(label=pgettext('Subject', 'As in "email subject"')) | ||
body = CharField(widget=Textarea, label=pgettext('Content', 'As in "content of an email"')) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of wger Workout Manager. | ||
# | ||
# wger Workout Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# wger Workout Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
|
||
from django.core import mail | ||
from django.conf import settings | ||
|
||
from django.core.management.base import BaseCommand | ||
from wger.email.models import CronEntry | ||
|
||
|
||
class Command(BaseCommand): | ||
''' | ||
Sends the prepared mass emails | ||
''' | ||
|
||
def handle(self, *args, **options): | ||
''' | ||
Send some mails and remove them from the list | ||
''' | ||
if CronEntry.objects.count(): | ||
for email in CronEntry.objects.all()[:100]: | ||
mail.send_mail(email.log.subject, | ||
email.log.body, | ||
settings.DEFAULT_FROM_EMAIL, | ||
[email.email], | ||
fail_silently=True) | ||
email.delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
from django.conf import settings | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('gym', '0004_auto_20151003_2357'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CronEntry', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('email', models.EmailField(max_length=254)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Log', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('date', models.DateField(auto_now=True)), | ||
('subject', models.CharField(max_length=100)), | ||
('body', models.TextField()), | ||
('gym', models.ForeignKey(editable=False, to='gym.Gym')), | ||
('user', models.ForeignKey(editable=False, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='cronentry', | ||
name='log', | ||
field=models.ForeignKey(editable=False, to='email.Log'), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of wger Workout Manager. | ||
# | ||
# wger Workout Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# wger Workout Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
|
||
from django.contrib.auth.models import User | ||
from django.db import models | ||
|
||
from wger.gym.models import Gym | ||
|
||
|
||
class Log(models.Model): | ||
''' | ||
A log of a sent email | ||
''' | ||
|
||
date = models.DateField(auto_now=True) | ||
''' | ||
Date when the log was created | ||
''' | ||
|
||
user = models.ForeignKey(User, | ||
editable=False) | ||
''' | ||
The user that created the email | ||
''' | ||
|
||
gym = models.ForeignKey(Gym, | ||
editable=False, | ||
related_name='email_log' | ||
) | ||
''' | ||
Gym this log belongs to | ||
''' | ||
|
||
subject = models.CharField(max_length=100) | ||
''' | ||
The email subject | ||
''' | ||
|
||
body = models.TextField() | ||
''' | ||
The email body | ||
''' | ||
|
||
def __unicode__(self): | ||
''' | ||
Return a more human-readable representation | ||
''' | ||
return self.subject | ||
|
||
|
||
class CronEntry(models.Model): | ||
''' | ||
Simple list of emails to be sent by a cron job | ||
''' | ||
|
||
log = models.ForeignKey(Log, | ||
editable=False) | ||
''' | ||
Foreign key to email log with subject and body | ||
''' | ||
|
||
email = models.EmailField() | ||
''' | ||
The email address | ||
''' | ||
|
||
def __unicode__(self): | ||
''' | ||
Return a more human-readable representation | ||
''' | ||
return self.email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{% extends "base.html" %} | ||
{% load wger_extras %} | ||
{% load i18n %} | ||
|
||
{% block title %} | ||
Emailverteiler - | ||
{% if email_type == 'starter' %} | ||
Starter | ||
{% else %} | ||
Studio | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<form action="{{ form_action }}" | ||
method="post" | ||
class="form-horizontal"> | ||
{% render_form_fields form "Vorschau erzeugen" %} | ||
</form> | ||
{% endblock %} | ||
|
||
{% block sidebar %} | ||
<div class="well"> | ||
<h4>Benutzung</h4> | ||
<ol> | ||
<li>Geben Sie die nötigen Daten in das Formular ein.</li> | ||
<li>Die Manager bekommen eine Vorschau-Email, zur Kontrolle.</li> | ||
<li> | ||
Sie können beliebig oft den Inhalt korrigieren und über die | ||
Vorschau-Emails kontrollieren. | ||
</li> | ||
<li> | ||
Wenn Sie mit dem Inhalt zufrieden sind, können Sie die Emails | ||
freigeben, sie weden in den nächsten Studen automatisch | ||
verschickt | ||
</li> | ||
</ol> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{% extends "base.html" %} | ||
{% load wger_extras i18n %} | ||
|
||
{% block title %}{% Email %}{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<p>Bitte wählen Sie die Empfänger</p> | ||
|
||
<h4>Log</h4> | ||
<table class="table"> | ||
<tr> | ||
<th>{% trans "Date" %}</th> | ||
<th>Typ</th> | ||
<th>Betreff</th> | ||
</tr> | ||
{% for email in email_list %} | ||
<tr> | ||
<td>{{ email.date }}</td> | ||
<td>{{ email.get_type_display }}</td> | ||
<td>{{ email.subject }}</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
|
||
{% endblock %} | ||
|
||
{% block sidebar %} | ||
{% endblock %} |
Oops, something went wrong.