Пример #1
0
def index(request, lang):
    data = {'lang': lang}
    if lang not in LANGUAGES:
        return render_to_response('client/404.html', {'data': data}, RequestContext(request))
    contact_info = ContactInfo.objects.all()
    if contact_info:
        data['contact_info'] = contact_info[0]
    comments = Comment.objects.filter(deleted=False).order_by('-date')
    data['comments'] = comments
    order = ''
    if lang == 'es':
        order = 'spanish_name'
    elif lang == 'en':
        order = 'english_name'
    elif lang == 'de':
        order = 'german_name'
    elif lang == 'pt':
        order = 'portuguese_name'
    elif lang == 'fr':
        order = 'french_name'
    services_list = Service.objects.filter(deleted=False).order_by(order)
    data['services'] = services_list
    if request.method == 'POST':
        if 'btn_comment' in request.POST:
            content = request.POST['text_comment']
            comment = Comment(content=content)
            comment.save()
            return HttpResponseRedirect('/services/' + lang)
        elif 'btn_suggestion' in request.POST:
            content = request.POST['text_suggestion']
            suggestion = Suggestion(content=content)
            suggestion.save()
            return HttpResponseRedirect('/services/' + lang)
        elif 'btn_request' in request.POST:
            content = request.POST['request']
            contact_info = request.POST['contact_info']
            req = Request(content=content, contact_info=contact_info)
            req.save()
            return HttpResponseRedirect('/services/' + lang)
    return render_to_response('client/main/index.html', {'data': data}, RequestContext(request))
Пример #2
0
    def _create_draft_suggestion(self):
        suggestion = Suggestion()
        suggestion.owner = self.member.global_user
        suggestion.goal = self.goal
        suggestion.is_draft = True
        suggestion.save()

        revision = Revision()
        revision.title = "not set"
        revision.description = "not set"
        revision.suggestion = suggestion
        revision.save()

        return suggestion
Пример #3
0
    def _create_draft_suggestion(self):
        suggestion = Suggestion()
        suggestion.owner = self.member.global_user
        suggestion.goal = self.goal
        suggestion.is_draft = True
        suggestion.save()

        revision = Revision()
        revision.title = "not set"
        revision.description = "not set"
        revision.suggestion = suggestion
        revision.save()

        return suggestion
Пример #4
0
def services(request, lang):
    contact_info = ContactInfo.objects.all()
    comments = Comment.objects.filter(deleted=False).order_by('-date')
    data = {'lang': lang, 'comments': comments}
    if contact_info:
        data['contact_info'] = contact_info[0]
    if lang not in LANGUAGES:
        return render_to_response('client/404.html', {'data': data}, RequestContext(request))
    order = ''
    if lang == 'es':
        order = 'spanish_name'
    elif lang == 'en':
        order = 'english_name'
    elif lang == 'de':
        order = 'german_name'
    elif lang == 'pt':
        order = 'portuguese_name'
    elif lang == 'fr':
        order = 'french_name'
    if 'service' in request.GET:
        id = request.GET['service']
        error = False
        for x in range(0, len(str(id))):
            if not str(id)[x].isdigit():
                error = True
                break
        if not error:
            services_list = Service.objects.filter(deleted=False, id=int(id)).order_by(order)
            if not services_list:
                return render_to_response('client/404.html', {'data': data}, RequestContext(request))
            images = Image.objects.filter(deleted=False, service=services_list[0])
            if images:
                position = random.randrange(0, images.count())
                data['image'] = images[position]
            data['selected'] = True
            data['service'] = id
        else:
            return render_to_response('client/404.html', {'data': data}, RequestContext(request))
    else:
        services_list = Service.objects.filter(deleted=False).order_by(order)
        images = Image.objects.filter(deleted=False)
        if images:
                position = random.randrange(0, images.count())
                data['image'] = images[position]
    data['services'] = services_list
    data['images'] = images
    if request.method == 'POST':
        if 'btn_comment' in request.POST:
            content = request.POST['text_comment']
            comment = Comment(content=content)
            comment.save()
            return HttpResponseRedirect('/services/' + lang)
        elif 'btn_suggestion' in request.POST:
            content = request.POST['text_suggestion']
            suggestion = Suggestion(content=content)
            suggestion.save()
            return HttpResponseRedirect('/services/' + lang)
        elif 'btn_request' in request.POST:
            content = request.POST['request']
            contact_info = request.POST['contact_info']
            req = Request(content=content, contact_info=contact_info)
            req.save()
            return HttpResponseRedirect('/services/' + lang)
    return render_to_response('client/services/index.html', {'data': data}, RequestContext(request))
Пример #5
0
def index(request):
    employee_list = Userinfo.objects.all()
    if request.method=="POST":
        print(request.POST['title'])
        print(request.POST['people_array'])
      #  print(request.POST['file'])
        file = request.FILES['file']

        print(file)
        filename = file._name
        print(filename)
        file.chunks()

        people_list = str(request.POST['people_array'])
        people_list = people_list.split(',')
        upload_file = UploadFileModel()
        upload_file.file = file
        upload_file.title = filename
        upload_file.save()
        obj = Suggestion.objects.last()
        file_locate = int(obj.file_locate)+1
        for people in people_list:
            suggest = Suggestion()
            suggest.title = request.POST['title']
            suggest.sender = request.session['user_num']
            suggest.reciever = int(people.strip())
            suggest.sender_name = request.session['user_name']
            suggest.status = 0
            suggest.file = file
            suggest.file_locate = file_locate
            user = Userinfo.objects.get(user_num=suggest.reciever)
            suggest.reciever_name = user.user_name
            suggest.save()


        return render(request,'suggestion/index.html',{'employee_list':employee_list,'rank':request.session['user_rank']})
    else:
    #    employee_list = Userinfo.objects.all()

        return render(request,'suggestion/index.html',{'employee_list':employee_list,'rank':request.session['user_rank']})
Пример #6
0
    def __create_suggestions(self):
        self.yoga_bend = Suggestion()
        self.yoga_bend.goal = self.become_a_yogi
        self.yoga_bend.owner = self.user_mnieber
        self.yoga_bend.is_draft = False
        self.yoga_bend.image = "suggestions/KroukTom-710x300-crop.jpg"
        self.yoga_bend.slug = "bend-backwards"
        self.yoga_bend.save()

        yoga_bend = Revision()
        yoga_bend.title = "Bend backwards"
        yoga_bend.description = yoga_bend_content
        yoga_bend.suggestion = self.yoga_bend
        yoga_bend.save()

        self.yoga_meditate = Suggestion()
        self.yoga_meditate.goal = self.become_a_yogi
        self.yoga_meditate.owner = self.user_mnieber
        self.yoga_meditate.is_draft = False
        self.yoga_meditate.image = "suggestions/Yoga_Nidra.jpg"
        self.yoga_meditate.slug = "meditate-often"
        self.yoga_meditate.save()

        yoga_meditate = Revision()
        yoga_meditate.title = "Meditate often"
        yoga_meditate.description = yoga_meditate_content
        yoga_meditate.suggestion = self.yoga_meditate
        yoga_meditate.save()

        self.yoga_twist = Suggestion()
        self.yoga_twist.goal = self.become_a_yogi
        self.yoga_twist.owner = self.user_anders_om
        self.yoga_twist.is_draft = False
        self.yoga_twist.image = "suggestions/MC_AM06_00_sized2.jpg"
        self.yoga_twist.slug = "keep-twisting"
        self.yoga_twist.save()

        self.rev_yoga_twist = Revision()
        self.rev_yoga_twist.title = "Keep twisting"
        self.rev_yoga_twist.description = yoga_twist_content
        self.rev_yoga_twist.suggestion = self.yoga_twist
        self.rev_yoga_twist.save()

        time.sleep(1)

        self.rev_yoga_twist_2 = Revision()
        self.rev_yoga_twist_2.title = "Keep twisting"
        self.rev_yoga_twist_2.description = yoga_twist_2_content
        self.rev_yoga_twist_2.suggestion = self.yoga_twist
        self.rev_yoga_twist_2.save()

        self.yoga_acrobatics = Suggestion()
        self.yoga_acrobatics.goal = self.become_a_yogi
        self.yoga_acrobatics.owner = self.user_marie_houana
        self.yoga_acrobatics.is_draft = False
        self.yoga_acrobatics.image = "suggestions/yoga-acrobats.jpg"
        self.yoga_acrobatics.slug = "yoga-acrobatics"
        self.yoga_acrobatics.save()

        yoga_acrobatics = Revision()
        yoga_acrobatics.title = "Acrobatics"
        yoga_acrobatics.description = yoga_acrobatics_content
        yoga_acrobatics.suggestion = self.yoga_acrobatics
        yoga_acrobatics.save()
Пример #7
0
class Command(BaseCommand):
    help = \
        'Populates the database with example suggestions'

    def add_arguments(self, parser):
        pass

    def __migrate(self):
        if settings.DATABASES['default']['NAME'] == ":memory:":
            management.call_command('migrate', '--run-syncdb')
        else:
            management.call_command('migrate', '--run-syncdb')
            management.call_command(
                'makemigrations', 'goal', 'suggestion', 'review')
            management.call_command('migrate', '--fake-initial')

    def __make_global_user(self, username, password, first_name, last_name):
        user = User.objects.get_or_create(username=username)[0]
        user.set_password(password)
        user.first_name = first_name
        user.last_name = last_name
        user.save()

        global_user = GlobalUser()
        global_user.user = user
        global_user.save()

        return global_user

    def __create_superuser(self):
        management.call_command(
            'createsuperuser',
            '--noinput',
            username='******',
            email='*****@*****.**'
        )

        self.user_mnieber = self.__make_global_user(
            'mnieber', '***REMOVED***', 'Maarten', 'Nieber')

    def __create_users(self):
        self.user_anders_om = self.__make_global_user(
            "andersom", "***REMOVED***", "Anders", "Om")

        self.user_marie_houana = self.__make_global_user(
            "mhouana", "***REMOVED***", "Maria", "Houana")

    def __create_goal(self):
        self.become_a_yogi = Goal()
        self.become_a_yogi.owner = self.user_marie_houana
        self.become_a_yogi.title = "Become a yogi"
        self.become_a_yogi.is_draft = False
        self.become_a_yogi.save()

    def __create_members(self):
        self.yogi_mnieber = Member()
        self.yogi_mnieber.global_user = self.user_mnieber
        self.yogi_mnieber.goal = self.become_a_yogi
        self.yogi_mnieber.save()

        self.yogi_anders_om = Member()
        self.yogi_anders_om.global_user = self.user_anders_om
        self.yogi_anders_om.goal = self.become_a_yogi
        self.yogi_anders_om.save()

        self.yogi_marie_houana = Member()
        self.yogi_marie_houana.global_user = self.user_marie_houana
        self.yogi_marie_houana.goal = self.become_a_yogi
        self.yogi_marie_houana.save()

    def __create_suggestions(self):
        self.yoga_bend = Suggestion()
        self.yoga_bend.goal = self.become_a_yogi
        self.yoga_bend.owner = self.user_mnieber
        self.yoga_bend.is_draft = False
        self.yoga_bend.image = "suggestions/KroukTom-710x300-crop.jpg"
        self.yoga_bend.slug = "bend-backwards"
        self.yoga_bend.save()

        yoga_bend = Revision()
        yoga_bend.title = "Bend backwards"
        yoga_bend.description = yoga_bend_content
        yoga_bend.suggestion = self.yoga_bend
        yoga_bend.save()

        self.yoga_meditate = Suggestion()
        self.yoga_meditate.goal = self.become_a_yogi
        self.yoga_meditate.owner = self.user_mnieber
        self.yoga_meditate.is_draft = False
        self.yoga_meditate.image = "suggestions/Yoga_Nidra.jpg"
        self.yoga_meditate.slug = "meditate-often"
        self.yoga_meditate.save()

        yoga_meditate = Revision()
        yoga_meditate.title = "Meditate often"
        yoga_meditate.description = yoga_meditate_content
        yoga_meditate.suggestion = self.yoga_meditate
        yoga_meditate.save()

        self.yoga_twist = Suggestion()
        self.yoga_twist.goal = self.become_a_yogi
        self.yoga_twist.owner = self.user_anders_om
        self.yoga_twist.is_draft = False
        self.yoga_twist.image = "suggestions/MC_AM06_00_sized2.jpg"
        self.yoga_twist.slug = "keep-twisting"
        self.yoga_twist.save()

        self.rev_yoga_twist = Revision()
        self.rev_yoga_twist.title = "Keep twisting"
        self.rev_yoga_twist.description = yoga_twist_content
        self.rev_yoga_twist.suggestion = self.yoga_twist
        self.rev_yoga_twist.save()

        time.sleep(1)

        self.rev_yoga_twist_2 = Revision()
        self.rev_yoga_twist_2.title = "Keep twisting"
        self.rev_yoga_twist_2.description = yoga_twist_2_content
        self.rev_yoga_twist_2.suggestion = self.yoga_twist
        self.rev_yoga_twist_2.save()

        self.yoga_acrobatics = Suggestion()
        self.yoga_acrobatics.goal = self.become_a_yogi
        self.yoga_acrobatics.owner = self.user_marie_houana
        self.yoga_acrobatics.is_draft = False
        self.yoga_acrobatics.image = "suggestions/yoga-acrobats.jpg"
        self.yoga_acrobatics.slug = "yoga-acrobatics"
        self.yoga_acrobatics.save()

        yoga_acrobatics = Revision()
        yoga_acrobatics.title = "Acrobatics"
        yoga_acrobatics.description = yoga_acrobatics_content
        yoga_acrobatics.suggestion = self.yoga_acrobatics
        yoga_acrobatics.save()

    def __create_reviews(self):
        self.review_yoga_twist = Review()
        self.review_yoga_twist.owner = self.user_marie_houana
        self.review_yoga_twist.revision = self.rev_yoga_twist
        self.review_yoga_twist.rating = 2.5
        self.review_yoga_twist.description = "Not bad!"
        self.review_yoga_twist.is_draft = False
        self.review_yoga_twist.save()

        self.review_yoga_twist_2 = Review()
        self.review_yoga_twist_2.owner = self.user_mnieber
        self.review_yoga_twist_2.revision = self.rev_yoga_twist_2
        self.review_yoga_twist_2.rating = 4
        self.review_yoga_twist_2.description = "Good, good, good"
        self.review_yoga_twist_2.is_draft = False
        self.review_yoga_twist_2.save()

    def __create_comments(self):
        self.comment_1 = Comment()
        self.comment_1.owner = self.user_mnieber
        self.comment_1.body = "Thanks for the feedback"
        self.comment_1.review = self.review_yoga_twist
        self.comment_1.is_draft = False
        self.comment_1.save()

        self.comment_2 = Comment()
        self.comment_2.owner = self.user_anders_om
        self.comment_2.body = "I see your point"
        self.comment_2.review = self.review_yoga_twist
        self.comment_2.reply_to = self.comment_1
        self.comment_2.is_draft = False
        self.comment_2.save()

    def handle(self, *args, **options):
        management.call_command('initdb')
        self.__migrate()
        self.__create_superuser()
        self.__create_users()
        self.__create_goal()
        self.__create_members()
        self.__create_suggestions()
        self.__create_reviews()
        self.__create_comments()
Пример #8
0
    def __create_suggestions(self):
        self.yoga_bend = Suggestion()
        self.yoga_bend.goal = self.become_a_yogi
        self.yoga_bend.owner = self.user_mnieber
        self.yoga_bend.is_draft = False
        self.yoga_bend.image = "suggestions/KroukTom-710x300-crop.jpg"
        self.yoga_bend.slug = "bend-backwards"
        self.yoga_bend.save()

        yoga_bend = Revision()
        yoga_bend.title = "Bend backwards"
        yoga_bend.description = yoga_bend_content
        yoga_bend.suggestion = self.yoga_bend
        yoga_bend.save()

        self.yoga_meditate = Suggestion()
        self.yoga_meditate.goal = self.become_a_yogi
        self.yoga_meditate.owner = self.user_mnieber
        self.yoga_meditate.is_draft = False
        self.yoga_meditate.image = "suggestions/Yoga_Nidra.jpg"
        self.yoga_meditate.slug = "meditate-often"
        self.yoga_meditate.save()

        yoga_meditate = Revision()
        yoga_meditate.title = "Meditate often"
        yoga_meditate.description = yoga_meditate_content
        yoga_meditate.suggestion = self.yoga_meditate
        yoga_meditate.save()

        self.yoga_twist = Suggestion()
        self.yoga_twist.goal = self.become_a_yogi
        self.yoga_twist.owner = self.user_anders_om
        self.yoga_twist.is_draft = False
        self.yoga_twist.image = "suggestions/MC_AM06_00_sized2.jpg"
        self.yoga_twist.slug = "keep-twisting"
        self.yoga_twist.save()

        self.rev_yoga_twist = Revision()
        self.rev_yoga_twist.title = "Keep twisting"
        self.rev_yoga_twist.description = yoga_twist_content
        self.rev_yoga_twist.suggestion = self.yoga_twist
        self.rev_yoga_twist.save()

        time.sleep(1)

        self.rev_yoga_twist_2 = Revision()
        self.rev_yoga_twist_2.title = "Keep twisting"
        self.rev_yoga_twist_2.description = yoga_twist_2_content
        self.rev_yoga_twist_2.suggestion = self.yoga_twist
        self.rev_yoga_twist_2.save()

        self.yoga_acrobatics = Suggestion()
        self.yoga_acrobatics.goal = self.become_a_yogi
        self.yoga_acrobatics.owner = self.user_marie_houana
        self.yoga_acrobatics.is_draft = False
        self.yoga_acrobatics.image = "suggestions/yoga-acrobats.jpg"
        self.yoga_acrobatics.slug = "yoga-acrobatics"
        self.yoga_acrobatics.save()

        yoga_acrobatics = Revision()
        yoga_acrobatics.title = "Acrobatics"
        yoga_acrobatics.description = yoga_acrobatics_content
        yoga_acrobatics.suggestion = self.yoga_acrobatics
        yoga_acrobatics.save()
Пример #9
0
class Command(BaseCommand):
    help = (
        'Populates the database with example suggestions'
    )

    def add_arguments(self, parser):
        pass

    def __migrate(self):
        if settings.DATABASES['default']['NAME'] == ":memory:":
            management.call_command('migrate', '--run-syncdb')
        else:
            management.call_command('migrate', '--run-syncdb')
            management.call_command(
                'makemigrations', 'goal', 'suggestion', 'review')
            management.call_command('migrate', '--fake-initial')

    def __make_global_user(self, username, password, first_name, last_name):
        user = User.objects.get_or_create(username=username)[0]
        user.set_password(password)
        user.first_name = first_name
        user.last_name = last_name
        user.save()

        global_user = GlobalUser()
        global_user.user = user
        global_user.save()

        return global_user

    def __create_superuser(self):
        management.call_command(
            'createsuperuser',
            '--noinput',
            username='******',
            email='*****@*****.**'
        )

        self.user_mnieber = self.__make_global_user(
            'mnieber', '***REMOVED***', 'Maarten', 'Nieber')

    def __create_users(self):
        self.user_anders_om = self.__make_global_user(
            "andersom", "***REMOVED***", "Anders", "Om")

        self.user_marie_houana = self.__make_global_user(
            "mhouana", "***REMOVED***", "Maria", "Houana")

    def __create_goal(self):
        self.become_a_yogi = Goal()
        self.become_a_yogi.owner = self.user_marie_houana
        self.become_a_yogi.title = "Become a yogi"
        self.become_a_yogi.is_draft = False
        self.become_a_yogi.save()

    def __create_members(self):
        self.yogi_mnieber = Member()
        self.yogi_mnieber.global_user = self.user_mnieber
        self.yogi_mnieber.goal = self.become_a_yogi
        self.yogi_mnieber.save()

        self.yogi_anders_om = Member()
        self.yogi_anders_om.global_user = self.user_anders_om
        self.yogi_anders_om.goal = self.become_a_yogi
        self.yogi_anders_om.save()

        self.yogi_marie_houana = Member()
        self.yogi_marie_houana.global_user = self.user_marie_houana
        self.yogi_marie_houana.goal = self.become_a_yogi
        self.yogi_marie_houana.save()

    def __create_suggestions(self):
        self.yoga_bend = Suggestion()
        self.yoga_bend.goal = self.become_a_yogi
        self.yoga_bend.owner = self.user_mnieber
        self.yoga_bend.is_draft = False
        self.yoga_bend.image = "suggestions/KroukTom-710x300-crop.jpg"
        self.yoga_bend.slug = "bend-backwards"
        self.yoga_bend.save()

        yoga_bend = Revision()
        yoga_bend.title = "Bend backwards"
        yoga_bend.description = yoga_bend_content
        yoga_bend.suggestion = self.yoga_bend
        yoga_bend.save()

        self.yoga_meditate = Suggestion()
        self.yoga_meditate.goal = self.become_a_yogi
        self.yoga_meditate.owner = self.user_mnieber
        self.yoga_meditate.is_draft = False
        self.yoga_meditate.image = "suggestions/Yoga_Nidra.jpg"
        self.yoga_meditate.slug = "meditate-often"
        self.yoga_meditate.save()

        yoga_meditate = Revision()
        yoga_meditate.title = "Meditate often"
        yoga_meditate.description = yoga_meditate_content
        yoga_meditate.suggestion = self.yoga_meditate
        yoga_meditate.save()

        self.yoga_twist = Suggestion()
        self.yoga_twist.goal = self.become_a_yogi
        self.yoga_twist.owner = self.user_anders_om
        self.yoga_twist.is_draft = False
        self.yoga_twist.image = "suggestions/MC_AM06_00_sized2.jpg"
        self.yoga_twist.slug = "keep-twisting"
        self.yoga_twist.save()

        self.rev_yoga_twist = Revision()
        self.rev_yoga_twist.title = "Keep twisting"
        self.rev_yoga_twist.description = yoga_twist_content
        self.rev_yoga_twist.suggestion = self.yoga_twist
        self.rev_yoga_twist.save()

        time.sleep(1)

        self.rev_yoga_twist_2 = Revision()
        self.rev_yoga_twist_2.title = "Keep twisting"
        self.rev_yoga_twist_2.description = yoga_twist_2_content
        self.rev_yoga_twist_2.suggestion = self.yoga_twist
        self.rev_yoga_twist_2.save()

        self.yoga_acrobatics = Suggestion()
        self.yoga_acrobatics.goal = self.become_a_yogi
        self.yoga_acrobatics.owner = self.user_marie_houana
        self.yoga_acrobatics.is_draft = False
        self.yoga_acrobatics.image = "suggestions/yoga-acrobats.jpg"
        self.yoga_acrobatics.slug = "yoga-acrobatics"
        self.yoga_acrobatics.save()

        yoga_acrobatics = Revision()
        yoga_acrobatics.title = "Acrobatics"
        yoga_acrobatics.description = yoga_acrobatics_content
        yoga_acrobatics.suggestion = self.yoga_acrobatics
        yoga_acrobatics.save()

    def __create_reviews(self):
        self.review_yoga_twist = Review()
        self.review_yoga_twist.owner = self.user_marie_houana
        self.review_yoga_twist.revision = self.rev_yoga_twist
        self.review_yoga_twist.rating = 2.5
        self.review_yoga_twist.description = "Not bad!"
        self.review_yoga_twist.is_draft = False
        self.review_yoga_twist.save()

        self.review_yoga_twist_2 = Review()
        self.review_yoga_twist_2.owner = self.user_mnieber
        self.review_yoga_twist_2.revision = self.rev_yoga_twist_2
        self.review_yoga_twist_2.rating = 4
        self.review_yoga_twist_2.description = "Good, good, good"
        self.review_yoga_twist_2.is_draft = False
        self.review_yoga_twist_2.save()

    def __create_comments(self):
        self.comment_1 = Comment()
        self.comment_1.owner = self.user_mnieber
        self.comment_1.body = "Thanks for the feedback"
        self.comment_1.review = self.review_yoga_twist
        self.comment_1.is_draft = False
        self.comment_1.save()

        self.comment_2 = Comment()
        self.comment_2.owner = self.user_anders_om
        self.comment_2.body = "I see your point"
        self.comment_2.review = self.review_yoga_twist
        self.comment_2.reply_to = self.comment_1
        self.comment_2.is_draft = False
        self.comment_2.save()

    def handle(self, *args, **options):
        management.call_command('initdb')
        self.__migrate()
        self.__create_superuser()
        self.__create_users()
        self.__create_goal()
        self.__create_members()
        self.__create_suggestions()
        self.__create_reviews()
        self.__create_comments()