<commit_before>from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, render_to_response
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.utils.text import slugify
from django.utils import timezone
from django.template import RequestContext
from django.db import transaction

from darkoob.group.forms import GroupForm, NewScheduleForm
from darkoob.group.models import Group
from darkoob.book.models import Quote
from darkoob.social.forms import NewPostForm
from darkoob.group.models import Post

def group(request, group_id, group_slug):
    template = 'group/group_page.html'

    group = Group.objects.get(id=group_id)
    quote = Quote.get_random_quote()
    if request.is_ajax():
        template = 'post/posts.html'

    if group and group_slug == slugify(group.name):
        #group.admins = group.admin.admin_set.all()
        #group.members = group.members.all()

        is_member = False
        if group in request.user.group_set.all():
            is_member = True

        posts = Post.objects.filter(group=group).order_by("-submitted_time").all()

        # Calculate Deadlines for group
        book_deadlines = []
        for schedule in group.schedule_set.all():
            deadline_set = schedule.deadline_set.exclude(end_time__lte=timezone.now())
            for i in range(len(deadline_set)):
                deadline_set[i].time_percentage = (timezone.now() - deadline_set[i].start_time).total_seconds()  / (deadline_set[i].end_time - deadline_set[i].start_time).total_seconds() * 100
            if deadline_set:
                book_deadlines.append([ schedule.book , deadline_set])

        # Is this user admin of group?
        is_admin = False
        if request.user == group.admin:
            is_admin = True
        return render(request, template, {
            'group': group,
            'posts': posts,
            'quote': quote,
            'new_post_form': NewPostForm,
            'is_member': is_member,
            'is_admin': is_admin,
            'book_deadlines': book_deadlines,
            'schedule_form': NewScheduleForm(),<commit_msg>bug in add deadline<commit_after>from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, render_to_response
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.utils.text import slugify
from django.utils import timezone
from django.template import RequestContext
from django.db import transaction

from darkoob.group.forms import GroupForm, NewScheduleForm
from darkoob.group.models import Group
from darkoob.book.models import Quote
from darkoob.social.forms import NewPostForm
from darkoob.group.models import Post

def group(request, group_id, group_slug):
    template = 'group/group_page.html'

    group = Group.objects.get(id=group_id)
    quote = Quote.get_random_quote()
    if request.is_ajax():
        template = 'post/posts.html'

    if group and group_slug == slugify(group.name):
        #group.admins = group.admin.admin_set.all()
        #group.members = group.members.all()

        is_member = False
        if group in request.user.group_set.all():
            is_member = True

        posts = Post.objects.filter(group=group).order_by("-submitted_time").all()

        # Calculate Deadlines for group
        book_deadlines = []
        for schedule in group.schedule_set.all():
            deadline_set = schedule.deadline_set.exclude(end_time__lte=timezone.now())
            for i in range(len(deadline_set)):
                deadline_set[i].time_percentage = (timezone.now() - deadline_set[i].start_time).total_seconds()  / (deadline_set[i].end_time - deadline_set[i].start_time).total_seconds() * 100
            if deadline_set:
                book_deadlines.append([ schedule.book , deadline_set])

        # Is this user admin of group?
        is_admin = False
        if request.user.id == group.admin.id:
            is_admin = True
        print is_admin
        return render(request, template, {
            'group': group,
            'posts': posts,
            'quote': quote,
            'new_post_form': NewPostForm,
            'is_member': is_member,
            'is_admin': is_admin,
            'book_deadlines': book_deadlines,
            'schedule_form': NewScheduleForm(),
{'fraction_non_alphanumeric': 0.0955832389580974, 'fraction_numerical': 0.0013590033975084937, 'mean_word_length': 2.9079646017699115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7211043', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1257, 'n_words': 296}