Ejemplo n.º 1
0
def now(request, type):
    type = type or "week"
    today = localtime(djnow())
    if type == "week":  # FIXME: should use ISO 8601
        year, num = today.isocalendar()[:2]
    elif type == "month":
        year = today.year
        num = today.month
    if request.GET.get("autorefresh"):
        return cal(request, year, num, type)
    else:
        return HttpResponseRedirect(reverse("rcal.cal", args=(type, year, num)))
Ejemplo n.º 2
0
    def setUp(self):
        #Groups and Permissions

        #Users
        self.larzipan = User.objects.create_superuser('larzipan',
                                                      '*****@*****.**',
                                                      'password')
        self.bana = User.objects.create_user('bananarchist',
                                             '*****@*****.**',
                                             'password')
        #Categories
        self.news_cat = Category.objects.create(
            title="News", description="Be careful what you wish for")
        self.gen_cat = Category.objects.create(title="General",
                                               description="Samesies")
        #Tags
        self.tags = [
            Tag.objects.create(text='spam'),
            Tag.objects.create(text='backend'),
            Tag.objects.create(text='robots'),
            Tag.objects.create(text='riviera')
        ]
        #Threads
        self.t1 = Thread.objects.create(creator=self.larzipan,
                                        title="Site Testing",
                                        text="Loreum",
                                        category=self.news_cat)
        self.t1.tags.add(self.tags[1])
        self.t2 = Thread.objects.create(creator=self.bana,
                                        title="The Longest Thread Ever",
                                        text="MAKE IT LONG",
                                        category=self.gen_cat)
        self.t2.tags.add(self.tags[0])
        self.t3 = Thread.objects.create(creator=self.larzipan,
                                        title="Unpublished",
                                        text='Roborotiiiiii',
                                        category=self.gen_cat,
                                        date_published=datetime.datetime(
                                            datetime.datetime.now().year + 1,
                                            1, 1))
        self.t3.tags.add(self.tags[1])
        #Recs
        rec = Requirement.objects.create(
            text="Most contain a reference to robosexuality")
        #Challenges
        chall = Challenge.objects.create(title="Roborotica",
                                         news=self.t1,
                                         date_expires=djnow())
        chall.recs.add(rec)
        #Other
        self.factory = RequestFactory()
Ejemplo n.º 3
0
    def setUp(self):
        #Groups and Permissions

        #Users
        self.larzipan = User.objects.create_superuser('larzipan',
                                                      '*****@*****.**',
                                                      'password')
        self.bana = User.objects.create_user('bananarchist',
                                             '*****@*****.**',
                                             'password')
        #Tags
        self.tags = [
            Tag.objects.create(text='spam'),
            Tag.objects.create(text='backend'),
            Tag.objects.create(text='robots'),
            Tag.objects.create(text='riviera')
        ]
        #Categories
        self.news_cat = Category.objects.create(
            title="News", description="Be careful what you wish for")
        #Threads
        self.t1 = Thread.objects.create(creator=self.larzipan,
                                        title="Site Testing",
                                        text="Loreum",
                                        category=self.news_cat)
        self.t1.tags.add(self.tags[1])
        #Recs
        rec = Requirement.objects.create(
            text="Most contain a reference to robosexuality")
        #Challenges
        chall = Challenge.objects.create(title="Roborotica",
                                         news=self.t1,
                                         date_expires=djnow())
        chall.recs.add(rec)
        #Decks
        self.deck1 = Deck.objects.create(
            title='Deck 1',
            creator=self.larzipan,
            deck_length_coefficient=33,
            deck_width_coefficient=9,
            deck_image='img/2013/10/20/1_1dnrm.png')
        self.deck1.tags.add(self.tags[2])
        self.deck1.tags.add(self.tags[1])
        #BinaryPolls
        BinaryPoll.objects.create(question="Like?", poll=self.deck1)
        BinaryPoll.objects.create(question="Would you buy this?",
                                  poll=self.deck1)
        #Other
        self.factory = RequestFactory()
Ejemplo n.º 4
0
class ExpenseItems(models.Model):
    instructor = models.ForeignKey(User, on_delete=models.CASCADE)
    date = models.DateField(null=True, blank=True, default=djnow())
    item = models.ForeignKey(ExpenseCategories, on_delete=models.CASCADE)
    quantity = models.IntegerField(default='0')
    net_amount = models.DecimalField(max_digits=8, decimal_places=2, blank=False, default=Decimal('0.00'))
    vat = models.DecimalField(max_digits=3, decimal_places=2, blank=False, default=Decimal('0.00'))
    brut_amount = models.DecimalField(max_digits=8, decimal_places=2, blank=False, default=Decimal('0.00'))

    class Meta:
        ordering = ['date', 'item']
        permissions = (('can_see_all_financials', 'Show all financials'), ('can_see_own_financials', 'Show own financials'))
    
    def __str__(self):
        return f'Expense Item {self.item.name}'
Ejemplo n.º 5
0
class Salary(models.Model):
    instructor = models.ForeignKey(User, on_delete=models.CASCADE)
    date = models.DateField(null=True, blank=False, default=djnow())
    item = models.ForeignKey(IncomeCategories, on_delete=models.CASCADE)
    income_item = models.ForeignKey(IncomeItems, on_delete=models.CASCADE)
    salary = models.DecimalField(max_digits=8, decimal_places=2, blank=False, default=Decimal('0.00'))

    class Meta:
        ordering = ['-id', 'date', 'instructor', 'item']

    def get_absolute_url(self):
        return reverse('salary', kwargs={'pk': self.pk})
    
    def __str__(self):
        return f'Salary {self.instructor.get_full_name()}, {self.date}, {self.item.name}, {self.salary}, IncomeItem_id: {self.income_item.id}'
Ejemplo n.º 6
0
def ics(request):
    domain = Site.objects.get_current().domain
    items = Event.objects.filter(end__gt=djnow())
    cal = vobject.iCalendar()
    cal.add("method").value = "PUBLISH"  # IE/Outlook needs this
    for item in EventAnonymizer.anonymize(request.user, items):
        vevent = cal.add("vevent")
        vevent.add("uid").value = "{0}@{1}".format(item.id, domain)
        vevent.add("summary").value = item.title
        vevent.add("dtstart").value = item.start
        vevent.add("dtend").value = item.end
        vevent.add("location").value = item.resource.name
    icalstream = cal.serialize()
    response = HttpResponse(icalstream, content_type="text/calendar")
    response["Filename"] = "cal.ics"  # IE needs this
    response["Content-Disposition"] = "attachment; filename=cal.ics"
    return response
Ejemplo n.º 7
0
class IncomeItems(models.Model):
    client = models.ForeignKey(User, on_delete=models.CASCADE, related_name='%(app_label)s_%(class)s_related')
    instructor = models.ForeignKey(User, on_delete=models.CASCADE)
    date = models.DateField(null=True, blank=True, default=djnow())
    item = models.ForeignKey(IncomeCategories, on_delete=models.CASCADE)
    quantity = models.IntegerField(default='0')
    net_amount = models.DecimalField(max_digits=8, decimal_places=2, blank=False, default=Decimal('0.00'))
    vat = models.DecimalField(max_digits=5, decimal_places=2, blank=False, default=Decimal('0.00'))
    brut_amount = models.DecimalField(max_digits=8, decimal_places=2, blank=False, default=Decimal('0.00'))

    class Meta:
        ordering = ['-id', 'date', 'item']
        permissions = (('can_see_all_financials', 'Show all financials'), ('can_see_own_financials', 'Show own financials'))

    def get_absolute_url(self):
        return reverse('accounting:incomeitems_update', kwargs={'pk': self.pk})
    
    def __str__(self):
        return f'Income Item {self.item.name}'
Ejemplo n.º 8
0
def now():
    return djnow()
Ejemplo n.º 9
0
 def key_expired(self):
     from django.utils.timezone import now as djnow
     expiration_date = self.sent + timedelta(
         days=settings.EMAIL_CONFIRMATION_DAYS)
     return expiration_date <= djnow()