http://appcamp.io/courses/user-interface/layout-simple
http://thompsonemerson.github.io/ionic-collection/
## ionic examples
ionic start ionicApp
ionic start blankApp blank
ionic start tabsApp tabs
This file contains hidden or 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
from django.db import models | |
from django.conf import settings | |
import dropbox | |
class RequestToken(models.Model): | |
key = models.CharField(max_length=100) | |
secret = models.CharField(max_length=100) | |
user = models.ForeignKey('auth.User') |
This file contains hidden or 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
# Add this to your common app in a file called `backends.py` | |
from logging import getLogger | |
from django.core.mail.backends.filebased import EmailBackend as FBEmailBackend | |
from django.core.mail.backends.smtp import EmailBackend as SmtpEmailBackend | |
class LoggingFileBasedEmailBackend(FBEmailBackend): | |
"""A wrapper around ``filebased.EmailBackend`` that logs every email. |
This file contains hidden or 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
from django_auth_ldap.backend import LDAPBackend, _LDAPUser | |
class LDAPUsernameBackend(LDAPBackend): | |
settings_prefix = "AUTH_LDAP_U_" | |
class LDAPEmailBackend(LDAPBackend): | |
settings_prefix = "AUTH_LDAP_E_" |
This file contains hidden or 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
### models.py | |
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager | |
from django.core.mail import send_mail | |
from django.db import models | |
from django.utils import timezone | |
from django.utils.translation import ugettext_lazy as _ | |
class UserManager(BaseUserManager): | |
use_in_migrations = True |
This file contains hidden or 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
# in settings.py | |
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | |
EMAIL_USE_TLS = True | |
EMAIL_HOST = 'smtp.gmail.com' | |
EMAIL_PORT = 587 | |
EMAIL_HOST_USER = '[email protected]' | |
EMAIL_HOST_PASSWORD = '...' |
This file contains hidden or 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
import threading | |
from allauth.account.adapter import DefaultAccountAdapter | |
class BackgroundEmailSendingAccountAdapter(DefaultAccountAdapter): | |
def send_mail(self, template_prefix, email, context): | |
mailing_thread = threading.Thread( | |
target=super(BackgroundEmailSendingAccountAdapter, self).send_mail, | |
args=(template_prefix, email, context) |
This file contains hidden or 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
.state('tab.referral-registration-form', { | |
url: '/register/referral/form', | |
views: { | |
'tab-dash': { | |
templateUrl: 'templates/dash-referral-registration/dash-referral_form.html', | |
controller: 'RegisterReferralFormCtrl' | |
} | |
} | |
}) | |
.state('tab.referral-registration-ack', { |
This file contains hidden or 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
def get_resultfile_upload_destination(instance, filename): | |
return "complaint/00_generic/farmerid_{farmerid}/{file}".format(farmerid=instance.farmer.id, file=filename) | |
class Complaint(models.Model): | |
farmer = models.ForeignKey(Farmer) | |
file = models.FileField(blank=True, default='', upload_to=get_resultfile_upload_destination) | |
text = models.TextField(blank=True, default='') | |
timestamp = models.DateTimeField(auto_now=True) |
This file contains hidden or 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
@classmethod | |
def get_total_hours(self): | |
'''Sum of all hours ever added''' | |
return GhanaECG.objects.all().aggregate(Sum('off_hours')) | |
@classmethod | |
def get_today_hours(self): | |
'''Sum of all hours submitted today''' | |
end_time = datetime.now() | |
start_time = datetime(end_time.year,end_time.month,end_time.day) |