Skip to content

Commit

Permalink
Merge pull request #34 from juann9/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Alejandro Peralta committed Aug 21, 2012
2 parents 6636604 + cddff84 commit 086b993
Show file tree
Hide file tree
Showing 30 changed files with 85 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ eff_site/updatedb.flag
local_settings.py
scripts/sources_csv/*
!.gitignore
tmpvar
21 changes: 12 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Dependencies
Dependencies
============
* django-profiles
* mysqldb (if you use DotProject as source)
Expand Down Expand Up @@ -84,10 +84,14 @@ When you run syncdb (or migrate if you have installed south) the following defau
* linkedin

Weekly reports to users
-----------------------
----------------------------
Eff can send reports by emails weekly to users not clients if they are checked this option in his settings. Your server need to call send_report.py script in the weekday you want to send emails.

You have to configure this script before to use, editing eff_site/scripts/send_report.py:
For this to work add this variable in local_settings.py to configure the sender:

DEFAULT_FROM_EMAIL = 'from@domain.com'

You also have to configure this script: eff_site/scripts/send_report.py

The emails are sent the day of the week defined by the variable SEND_DAY (default is set to 0 (Monday)), if your server calls the script on a day other than the set, are not going to send the mails::

Expand All @@ -100,13 +104,12 @@ To customize the email template you need to edit the following files:
* eff_site/templates/previous_week_report_subject.txt


Optional
--------
This options is for test sending mails::
Other email configurations
--------------------------------
Config this variables in local_settings.py for Eff to be able to send emails regarding different topics, like change/reset password.

# Config Email for testing
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
EMAIL_HOST = 'smtphost'
EMAIL_PORT = # smtp port number

Sources
=======
Expand Down
6 changes: 3 additions & 3 deletions eff_site/README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
=======
=======
Install
=======
Add data base credentials here:

If you are going to use a DotProject source:

* sitio/scripts/dotproject.py::
* eff_site/scripts/dotproject.py::

class Machinalis(DotProject):
...
Expand All @@ -14,7 +14,7 @@ If you are going to use a DotProject source:
PASSWD = ''
...

* sitio/settings.py::
* eff_site/settings.py::

DATABASE_NAME = '' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
Expand Down
1 change: 0 additions & 1 deletion eff_site/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
#
# You should have received a copy of the GNU General Public License
# along with Eff. If not, see <http://www.gnu.org/licenses/>.

1 change: 0 additions & 1 deletion eff_site/eff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
#
# You should have received a copy of the GNU General Public License
# along with Eff. If not, see <http://www.gnu.org/licenses/>.

2 changes: 1 addition & 1 deletion eff_site/eff/_models/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with Eff. If not, see <http://www.gnu.org/licenses/>.

from django.db import models
#from external_source import ExternalSource


class Dump(models.Model):
date = models.DateField()
Expand Down
14 changes: 7 additions & 7 deletions eff_site/eff/_models/user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with Eff. If not, see <http://www.gnu.org/licenses/>.

from django.db import models
from django.contrib.auth.models import User, Group
from django.contrib.auth.models import User
from datetime import timedelta, datetime
from avg_hours import AvgHours
from client import Client
Expand Down Expand Up @@ -131,19 +131,19 @@ def add_avg_hours(self, new_date, hours):
new_avg_hour.validate_unique()
new_avg_hour.save()
else:
raise ValueError, "Negative value for hours"
raise ValueError("Negative value for hours")

def update_avg_hour(self, udate, hours):
if hours >= 0:
try:
update_date = self.user.avghours_set.get(date=udate)
except (AvgHours.DoesNotExist, MultipleObjectsReturned):
raise ValueError, "AvgHour inexistent"
raise ValueError("AvgHour inexistent")
else:
update_date.hours = hours
update_date.save()
else:
raise ValueError, "Negative value for hours"
raise ValueError("Negative value for hours")

def is_active(self, from_date, to_date):
delta = timedelta(days=1)
Expand Down Expand Up @@ -180,7 +180,7 @@ def percentage_hours_worked(self, from_date, to_date):
wh = self.get_worked_hours(from_date, to_date)
th = self.num_loggable_hours(from_date, to_date)
if th == 0:
raise ValueError, 'No loggable hours'
raise ValueError('No loggable hours')
else:
# For total values of this, see eff.utils.DataTotal
# phw must be a Decimal
Expand All @@ -191,7 +191,7 @@ def percentage_billable_hours(self, from_date, to_date):
bh = self.billable_hours(from_date, to_date)
th = self.num_loggable_hours(from_date, to_date)
if th == 0:
raise ValueError, 'No loggable hours'
raise ValueError('No loggable hours')
else:
# For total values of this, see eff.utils.DataTotal
# pbh must be a Decimal
Expand Down Expand Up @@ -229,7 +229,7 @@ def is_client(self):
def create_profile_for_user(sender, instance, signal, *args, **kwargs):
try:
profile = UserProfile.objects.get(user=instance)
except UserProfile.DoesNotExist, e:
except UserProfile.DoesNotExist:
#si no existe, creamos el profile para el usuario
profile = UserProfile(user=instance)
if hasattr(instance, "is_client"):
Expand Down
6 changes: 3 additions & 3 deletions eff_site/eff/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# along with Eff. If not, see <http://www.gnu.org/licenses/>.

from django.contrib import admin
from eff_site.eff.models import Project, Client, ExternalSource, Wage, BillingEmail
from eff_site.eff.models import (AvgHours, Currency, ProjectAssoc, TimeLog,
from eff_site.eff.models import (Project, Client, ExternalSource, Wage, Payment,
BillingEmail, Currency, ProjectAssoc, TimeLog,
Handle, ClientHandles, Billing, CreditNote,
Payment, CommercialDocumentBase)
AvgHours, CommercialDocumentBase)
from _models.user_profile import UserProfile
from eff_site.eff.forms import UserAdminForm, UserAdminChangeForm
from django.contrib.auth.models import User
Expand Down
26 changes: 13 additions & 13 deletions eff_site/eff/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def format_report_data(rep, client, from_date, to_date, detailed=False):
'hs': str(user[1].quantize(Decimal('.000')))}
# Include rates in report
if len(user) > 2:
user_total = (user[1] * user[2]).quantize(Decimal('.000'))
user_total = (user[1] * user[2]).quantize(Decimal('.00'))
total_sum += user_total
user_d.update(
{'rate': str(user[2].quantize(Decimal('.00'))),
Expand Down Expand Up @@ -89,13 +89,13 @@ def format_report_data(rep, client, from_date, to_date, detailed=False):
or client.currency.ccy_code),
}
reverse_billing = ClientReverseBilling(
projects_users = report_list,
client_data = client_data,
invoice_period = format_invoice_period(from_date, to_date),
reference = "%s%s%s" % (client.name.lower(), from_date.year,
projects_users=report_list,
client_data=client_data,
invoice_period=format_invoice_period(from_date, to_date),
reference="%s%s%s" % (client.name.lower(), from_date.year,
from_date.strftime("%m"), ),
today = datetime.now().strftime("%A, %d %B %Y"),
total = str(total_sum))
today=datetime.now().strftime("%A, %d %B %Y"),
total=str(total_sum))
return reverse_billing


Expand Down Expand Up @@ -147,16 +147,16 @@ def format_report_data_user(rep, user, from_date, to_date, detailed=False):
user_data.update({'total_hs': totalHrs})

reverse_billing = UserReverseBilling(
user_hours = report_list,
sub_total = sub_total,
user_data = user_data,
invoice_period = format_invoice_period(from_date, to_date),
reference = "%s_%s%s%s" % (
user_hours=report_list,
sub_total=sub_total,
user_data=user_data,
invoice_period=format_invoice_period(from_date, to_date),
reference="%s_%s%s%s" % (
user.first_name.lower(),
user.last_name.lower(),
from_date.year,
from_date.strftime("%m"),
),
today = datetime.now().strftime("%A, %d %B %Y")
today=datetime.now().strftime("%A, %d %B %Y")
)
return reverse_billing
1 change: 0 additions & 1 deletion eff_site/eff/templatetags/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
#
# You should have received a copy of the GNU General Public License
# along with Eff. If not, see <http://www.gnu.org/licenses/>.

3 changes: 2 additions & 1 deletion eff_site/eff/templatetags/attachments_tags_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def __init__(self, ctype=None, object_id_expr=None, object_expr=None,

def render(self, context):
qs = self.get_query_set(context)
context[self.as_varname] = self.get_context_value_from_queryset(context, qs)
context[self.as_varname] = self.get_context_value_from_queryset(context,
qs)
return ''

def get_query_set(self, context):
Expand Down
1 change: 0 additions & 1 deletion eff_site/eff/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
#
# You should have received a copy of the GNU General Public License
# along with Eff. If not, see <http://www.gnu.org/licenses/>.

10 changes: 5 additions & 5 deletions eff_site/eff/testing/testModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def test_profile_details(self):
usr = User.objects.get(username='test1')
profile_from_db = usr.get_profile()

self.assertEqual(usr.get_profile().address, profile.address)
self.assertEqual(usr.get_profile().phone_number, profile.phone_number)
self.assertEqual(profile_from_db.address, profile.address)
self.assertEqual(profile_from_db.phone_number, profile.phone_number)

def test_update_hours_requires_login(self):
response = self.client.post('/updatehours/test1/')
Expand Down Expand Up @@ -356,7 +356,8 @@ def test_add_existing_user(self):
response = self.client.post('/efi/administration/add_user/', context)
self.assertEqual(response.status_code, 200)
self.assert_('Invalid Form' in response.context[0]['errors'])
self.assert_('User already exists.' in response.context[0]['form'].errors['__all__'])
self.assert_('User already exists.' in
response.context[0]['form'].errors['__all__'])

def test_add_user_getparm(self):
self.assert_(self.client.login(username='test1', password='test1'))
Expand All @@ -367,7 +368,6 @@ def test_add_user_getparm(self):
'test2')

def test_client_report_access(self):
from eff.models import Client as EffClient
cli_name = "test client, test.client....;(*&^$#@"
from django.template.defaultfilters import slugify
source, is_done = ExternalSource.objects.get_or_create(name='Example')
Expand Down Expand Up @@ -494,6 +494,7 @@ def test_include_navlinks_into_eff_charts(self):
self._test_prev_next_button('efi/chart/admin/?from_date=2008-03-04'\
'&to_date=2008-04-29')


class UserCreationTest(TestCase):

def setUp(self):
Expand All @@ -516,7 +517,6 @@ def test_group_attachment_added_to_new_user(self):
name='attachments'))



class UserProfileCreationTest(TestCase):

def test_user_profile_created_automatically(self):
Expand Down
3 changes: 2 additions & 1 deletion eff_site/eff/testing/testUserReportsPerms.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ def test_can_only_see_himself(self):
response = self.get_response()
query = PyQuery(response.content)
query = query('table#queryTable td.name').text()
name = self.no_perms_user.user.username
name = '%s %s' % (self.no_perms_user.user.first_name,
self.no_perms_user.user.last_name)
self.assertEqual(query, name)

def test_can_see_his_report(self):
Expand Down
4 changes: 3 additions & 1 deletion eff_site/eff/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class Data (object):
def __init__(self, profile, from_date, to_date):
self.username = profile.user.username
self.name = profile.user.first_name or profile.user.username
fancy_name = "%s %s" % (profile.user.first_name, profile.user.last_name)
self.fancy_name = fancy_name.strip() and fancy_name or self.name
self.url = profile.get_absolute_url()
self.is_active = profile.is_active(from_date, to_date)
self.worked_hours = profile.get_worked_hours(from_date, to_date)
Expand Down Expand Up @@ -368,7 +370,7 @@ def validate_header(file_obj):
"""

ERROR_FILE_HEADER = "Line %d in file header doesnot start with '#'"
ERROR_FILE_HEADER = "Line %d in file header does not start with '#'"
ERROR_BAD_FORMAT = "No ':' separating the arguments at line: %d"
ERROR_NO_ARGUMENT = "No argument at line: %d"

Expand Down
19 changes: 11 additions & 8 deletions eff_site/eff/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import operator

from urllib import quote, urlencode
from subprocess import Popen
from datetime import date, timedelta, datetime

from django.shortcuts import render_to_response, get_object_or_404, redirect
Expand Down Expand Up @@ -465,7 +466,8 @@ def eff_client_projects(request):


@login_required
@user_passes_test(lambda u: __enough_perms_or_client(u), login_url='/accounts/login/')
@user_passes_test(lambda u: __enough_perms_or_client(u),
login_url='/accounts/login/')
def eff_client_summary_period(request):
"""
Renders a period selection to get a client's account summary
Expand Down Expand Up @@ -537,7 +539,8 @@ def eff_client_summary_period(request):


@login_required
@user_passes_test(lambda u: __enough_perms_or_client(u), login_url='/accounts/login/')
@user_passes_test(lambda u: __enough_perms_or_client(u),
login_url='/accounts/login/')
def eff_client_summary(request, company_slug=None):
"""
Renders a client's account summary.
Expand Down Expand Up @@ -731,7 +734,8 @@ def eff(request):
# month name
aux = "durante el mes de %s" % from_date.strftime('%B de %Y')
elif OVERTIME_FLAG in context:
aux = "durante el período de horas extras [%s, %s]" % (from_date, to_date)
aux = "durante el período de horas extras [%s, %s]" % (from_date,
to_date)
else:
aux = "entre %s y %s" % (from_date, to_date)
context['title'] = "Horas Logueadas %s" % aux
Expand Down Expand Up @@ -956,10 +960,9 @@ def eff_update_db(request):
' %H:%M'))
fd.close()

# We use a cron job to run the code below now
# args = (settings.PYTHON_BINARY, settings.FETCH_EXTERNALS_PATH)
# process = Popen(args, stdout=open(settings.DEBUG_FILE, 'w'),
# close_fds=True)
args = (settings.PYTHON_BINARY, settings.FETCH_EXTERNALS_PATH)
process = Popen(args, stdout=open(settings.DEBUG_FILE, 'w'),
close_fds=True)

response_data = dict(status='ok')
return HttpResponse(simplejson.dumps(response_data),
Expand Down Expand Up @@ -1321,7 +1324,7 @@ def eff_admin_users_association(request):
"""

context = {'title' : 'Asociación de usuarios'}
context = {'title': 'Asociación de usuarios'}
if 'log_entries_file' in request.session and 'n_users' in request.session:
n_users = request.session['n_users']
log_entries_file = request.session['log_entries_file']
Expand Down
2 changes: 1 addition & 1 deletion eff_site/media/css/eff-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ h1, #wrapper, #footer { text-align: center; }
.graphicsLeft { float: left; text-align: left }
.graphicsRight { text-align: right }

.main-menu-ul {list-style-image: url(none);list-style-position: outside;list-style-type: none;float: right;}
.main-menu-ul {list-style-position: outside;list-style-type: none;float: right;}
#main-menu li {display: inline;float: left;margin: 0;position: relative;width: 120px;text-align: center;background-color: #EEEEEE;height: 22px;}
#main-menu li a {color: #000000;display: block;padding: 2px 5px;text-decoration: none;width: 120px;background-color: #EEEEEE;}
#main-menu li ul {display: none;position: absolute;}
Expand Down
8 changes: 4 additions & 4 deletions eff_site/scripts/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-

# Association between external source name and external source fetcher
# Association between external source name and external source fetcher
# (must contain a specific fetch_all global function)

EXT_SRC_ASSOC = {
'DotprojectMachinalis' : 'dotproject',
'ProteonTutos' : 'tutos',
'ProteonJira' : 'jira',
'DotprojectMachinalis': 'dotproject',
'ProteonTutos': 'tutos',
'ProteonJira': 'jira',
}
Loading

0 comments on commit 086b993

Please sign in to comment.