Ejemplo n.º 1
0
 def all_results(self, request):
     self.log('-> GuildesView().all_results()')
     from _database.models import Guilde
     request = Request(request)
     all_results = Guilde.objects.all()[:10]
     self.context = {
         'view': 'results_list',
         'in_space': request.in_space,
         'hash': request.hash,
         'ADMIN_URL': self.admin_url,
         'user': request.user,
         'language': request.language,
         'auto_search': request.search,
         'slug': '/guildes',
         'page_git_url':
         '/tree/master/_database/templates/results_list.html',
         'page_name': self.space_name + ' | Guildes',
         'page_description': 'Join a guilde at ' + self.space_name + '!',
         'headline': 'Guildes',
         'description': 'A guilde is ...',
         'wiki_url': None,
         'add_new_requires_user': True,
         'addnew_url': '/{}/_database/guilde/add/'.format(self.admin_url),
         'addnew_text': 'Add guilde',
         'all_results': all_results if all_results else True,
         'results_count': Guilde.objects.count(),
         'show_more': 'guildes'
     }
Ejemplo n.º 2
0
    def result(self, request, sub_page):
        self.log('-> MeetingsView().result()')
        from _database.models import MeetingNote, Event
        request = Request(request)

        selected = MeetingNote.objects.filter(text_date=sub_page).first()

        if selected:
            self.context = {
                'view': 'meeting_view',
                'in_space': request.in_space,
                'hash': request.hash,
                'ADMIN_URL': self.admin_url,
                'user': request.user,
                'language': request.language,
                'auto_search': request.search,
                'slug': '/meeting/' + selected.text_date,
                'page_git_url':
                '/tree/master/_database/templates/meeting_view.html',
                'page_name':
                self.space_name + ' | Meeting | ' + selected.text_date,
                'page_description': 'Join our weekly meetings!',
                'selected': selected,
                'next_meeting': Event.objects.QUERYSET__next_meeting(),
                'past_meetings': MeetingNote.objects.past(selected)[:10]
            }

        else:
            self.context = redirect('/meetings')
Ejemplo n.º 3
0
 def all_results(self, request):
     self.log('-> MachinesView().all_results()')
     from _database.models import Machine
     request = Request(request)
     all_results = Machine.objects.all()[:10]
     self.context = {
         'view': 'results_list',
         'in_space': request.in_space,
         'hash': request.hash,
         'ADMIN_URL': self.admin_url,
         'user': request.user,
         'language': request.language,
         'auto_search': request.search,
         'slug': '/machines',
         'page_git_url':
         '/tree/master/_database/templates/results_list.html',
         'page_name': self.space_name + ' | Machines',
         'page_description':
         self.space_name + ' has all kinds of awesome machines!',
         'headline': 'Machines',
         'description': 'We have many useful machines ...',
         'wiki_url': None,
         'add_new_requires_user': True,
         'addnew_url': '/{}/_database/machine/add/'.format(self.admin_url),
         'addnew_text': 'Add machine',
         'all_results': all_results if all_results else True,
         'results_count': Machine.objects.count(),
         'show_more': 'machines'
     }
Ejemplo n.º 4
0
    def __init__(self, request):
        from _database.models import Event
        from django.http import JsonResponse
        from django.template.loader import get_template
        from _website.models import Request

        str_date = request.GET.get('date', None)
        str_time = request.GET.get('time', None)
        str_duration = request.GET.get('duration', None)
        if str_date and str_time and str_duration:
            from _database.models import Helper

            overlapping_events = Event.objects.JSON__overlapping_events(
                Helper().INT__UNIX_from_date_and_time_STR(str_date, str_time),
                Helper().INT__duration_minutes(str_duration),
                request.GET.get('space', None),
            )

            self.value = JsonResponse({
                'int_overlapping_events':
                len(overlapping_events['overlapping_events']),
                'html':
                get_template(
                    'components/body/event_new/form_elements/overlapping_events.html'
                ).render({
                    'language': Request(request).language,
                    'overlapping_events': overlapping_events
                })
            })
        else:
            self.value = JsonResponse({
                'error':
                'Variables missing - date, time and duration needed.'
            })
Ejemplo n.º 5
0
    def __init__(self, request):
        from django.http import JsonResponse
        from django.template.loader import get_template
        from _database.models import Event
        from _website.models import Request

        marry_messages = []
        in_space = request.COOKIES.get('in_space')
        if request:
            request = Request(request)
        if in_space:
            events_in_5_minutes = Event.objects.LIST__in_minutes(
                minutes=5, name_only=True)
            events_in_30_minutes = Event.objects.LIST__in_minutes(
                minutes=30, name_only=True)
            if events_in_5_minutes or events_in_30_minutes:
                marry_messages.append('We have some awesome events upcoming')
            for event in events_in_5_minutes:
                marry_messages.append(event + ' starts in 5 minutes.')
            for event in events_in_30_minutes:
                marry_messages.append(event + ' starts in 30 minutes.')

        self.value = JsonResponse({
            'html':
            get_template('components/body/events_slider.html').render({
                'language':
                request.language,
                'upcoming_events':
                Event.objects.QUERYSET__upcoming()[:5]
            }),
            'marryspeak':
            marry_messages
        })
Ejemplo n.º 6
0
    def result(self, request, sub_page):
        self.log('-> MachinesView().result()')
        from _database.models import Machine
        request = Request(request)

        if 'machine/' not in sub_page:
            sub_page = 'machine/' + sub_page
        selected = Machine.objects.filter(str_slug=sub_page).first()

        if selected:
            self.context = {
                'view': 'machine_view',
                'in_space': request.in_space,
                'hash': request.hash,
                'ADMIN_URL': self.admin_url,
                'user': request.user,
                'language': request.language,
                'auto_search': request.search,
                'slug': '/machine/' + sub_page,
                'page_git_url':
                '/tree/master/_database/templates/machine_view.html',
                'page_name':
                self.space_name + ' | Machine | ' + selected.str_name_en_US,
                'page_description': selected.text_description_en_US,
                'selected': selected
            }

        else:
            self.context = redirect('/machines')
Ejemplo n.º 7
0
 def all_results(self, request):
     self.log('-> EventsView().all_results()')
     request = Request(request)
     from _database.models import Event
     all_results = Event.objects.QUERYSET__upcoming()[:10]
     self.context = {
         'view': 'results_list',
         'in_space': request.in_space,
         'hash': request.hash,
         'ADMIN_URL': self.admin_url,
         'user': request.user,
         'language': request.language,
         'auto_search': request.search,
         'slug': '/events',
         'page_git_url':
         '/tree/master/_website/templates/results_list.html',
         'page_name': self.space_name + ' | Events',
         'page_description': 'At ' + self.space_name +
         ' we have all kinds of cool events - organized by your fellow hackers!',
         'headline': 'Events',
         'description':
         self.space_name + ' is a place where people come together ...',
         'add_new_requires_user': False,
         'addnew_url': '/event/new',
         'addnew_text': 'Organize an event',
         'addnew_target': 'same_tab',
         'addnew_menu_selected': 'menu_h_events',
         'all_results': all_results if all_results else True,
         'results_count': Event.objects.count(),
         'show_more': 'events'
     }
Ejemplo n.º 8
0
    def result(self, request, sub_page):
        self.log('-> EventsView().result()')
        from _database.models import Event, Photo
        request = Request(request)

        if 'event/' not in sub_page:
            sub_page = 'event/' + sub_page
        selected = Event.objects.filter(str_slug=sub_page).first()

        if selected:
            self.context = {
                'view': 'event_view',
                'in_space': request.in_space,
                'hash': request.hash,
                'ADMIN_URL': self.admin_url,
                'user': request.user,
                'language': request.language,
                'auto_search': request.search,
                'slug': '/event/' + sub_page,
                'page_git_url':
                '/tree/master/_database/templates/event_view.html',
                'page_name':
                self.space_name + ' | Event | ' + selected.str_name_en_US,
                'page_description': selected.text_description_en_US,
                'selected': selected,
                'photos': Photo.objects.latest()[:33]
            }

        else:
            self.context = redirect('/events')
Ejemplo n.º 9
0
    def all_results(self, request):
        self.log('-> SpacesView().all_results()')
        from _database.models import Space
        request = Request(request)
        all_results = Space.objects.all()[:10]

        self.context = {
            'view': 'results_list',
            'in_space': request.in_space,
            'hash': request.hash,
            'ADMIN_URL': self.admin_url,
            'user': request.user,
            'language': request.language,
            'auto_search': request.search,
            'slug': '/spaces',
            'page_git_url': '/tree/master/_database/templates/results_list.html',
            'page_name': self.space_name+' | Spaces',
            'page_description': self.space_name+' has many awesome spaces!',
            'headline': 'Spaces',
            'description': 'At {} fellow hackers created all kind of awesome spaces...'.format(self.space_name),
            'wiki_url': None,
            'add_new_requires_user': True,
            'addnew_url': '/{}/_database/space/add/'.format(self.admin_url),
            'addnew_text': 'Add space',
            'all_results': all_results if all_results else True,
            'results_count': Space.objects.count(),
            'show_more': 'spaces'
        }
Ejemplo n.º 10
0
    def get_context(self, request):
        self.log('ProjectsView.get_context()')
        from _database.models import Project
        from _setup.models import Secret

        request = Request(request)

        all_results = Project.objects.all()[:10]
        self.context = {
            'view':
            'results_list',
            'in_space':
            request.in_space,
            'hash':
            request.hash,
            'ADMIN_URL':
            self.admin_url,
            'user':
            request.user,
            'language':
            request.language,
            'auto_search':
            request.search,
            'slug':
            '/projects',
            'page_git_url':
            '/tree/master/_database/templates/results_list.html',
            'page_name':
            self.space_name + ' | Projects',
            'page_description':
            'People at ' + self.space_name +
            ' created all kinds of awesome projects!',
            'headline':
            'Projects',
            'description':
            'At {} fellow hackers created awesome projects...'.format(
                self.space_name),
            'wiki_url':
            None,
            'add_new_requires_user':
            False,
            'addnew_url':
            '{}c/projects/'.format(Secret('DISCOURSE.DISCOURSE_URL').value),
            'addnew_text':
            'Add project',
            'all_results':
            all_results if all_results else True,
            'results_count':
            Project.objects.count(),
            'show_more':
            'projects'
        }
Ejemplo n.º 11
0
 def present(self, request):
     self.log('-> MeetingsView().present()')
     from _database.models import MeetingNote
     request = Request(request)
     self.context = {
         'view': 'meeting_present',
         'user': request.user,
         'language': request.language,
         'slug': '/meeting/present',
         'page_name': self.space_name + ' | Meeting | Presentation mode',
         'page_description': 'Join our weekly meetings!',
         'current_meeting': MeetingNote.objects.current()
     }
Ejemplo n.º 12
0
    def __init__(self, request):
        from django.http import JsonResponse
        from django.template.loader import get_template
        from _website.models import Request

        self.value = JsonResponse({
            'success':
            True,
            'html':
            get_template(
                'components/body/meetings/current_meeting.html').render({
                    'language':
                    Request(request).language,
                })
        })
Ejemplo n.º 13
0
 def get_context(self, request):
     self.log('ValuesView.get_context()')
     request = Request(request)
     self.context = {
         'view': 'values_view',
         'in_space': request.in_space,
         'hash': request.hash,
         'ADMIN_URL': self.admin_url,
         'user': request.user,
         'language': request.language,
         'auto_search': request.search,
         'slug': '/values',
         'page_git_url': '/tree/master/_website/templates/values_view.html',
         'page_name': self.space_name + ' | Values',
         'page_description': 'Our values at ' + self.space_name
     }
Ejemplo n.º 14
0
    def banner(self, request, sub_page=None):
        self.log('-> EventsView().banner()')
        from _database.models import Event, Photo
        request = Request(request)

        if 'event/' not in sub_page:
            sub_page = 'event/' + sub_page
        selected = Event.objects.filter(str_slug=sub_page).first()

        if selected:
            self.context = {
                'view': 'event_banner_view',
                'user': request.user,
                'language': request.language,
                'selected': selected,
            }
        else:
            self.context = redirect('/events')
Ejemplo n.º 15
0
    def __init__(self, request):
        from datetime import datetime
        import calendar
        import pytz
        from _website.templatetags.translate import landingpage
        from _database.models import Event
        from _website.models import Request
        language = Request(request).language

        # if an event is happening - show space open. Else use opening hours defined by config.json
        if self.still_temporary and Config(
                'PHYSICAL_SPACE.TEMPORARY_LANDINGPAGE_HEADER.OPENING_STATUS'
        ).value:
            translated_status = Config(
                'PHYSICAL_SPACE.TEMPORARY_LANDINGPAGE_HEADER.OPENING_STATUS'
            ).value
            color_indicator = 'grey'
        elif Event.objects.QUERYSET__now():
            translated_status = landingpage('Open now', language)
            color_indicator = 'green'
        else:
            timezone = pytz.timezone('utc')
            #Config('PHYSICAL_SPACE.TIMEZONE_STRING').value)
            today_weekday = calendar.day_name[datetime.now(timezone).weekday()]
            now_hour = datetime.now(timezone).hour
            now_minute = datetime.now(timezone).minute
            status = 'Unknown'

            for status_change in Config(
                    'PHYSICAL_SPACE.OPENING_HOURS').value[today_weekday]:
                if now_hour >= status_change[
                        0] and now_minute >= status_change[1]:
                    status = status_change[2]
                    translated_status = landingpage(status, language)
                    color_indicator = status_change[3]
                else:
                    break
        if language == 'hebrew':
            self.value = '<div dir="rtl" align="right">'+translated_status + \
                '</div><div class="status_code_icon '+color_indicator+' rtl"></div>'
        else:
            self.value = '<div class="status_code_icon ' + \
                color_indicator+'"></div><div>'+translated_status+'</div>'
Ejemplo n.º 16
0
    def new(self, original_request):
        self.log('-> EventsView().new()')
        from _database.models import Event, Photo, Space, Guilde
        from _setup.models import Config
        from django.middleware.csrf import get_token
        request = Request(original_request)
        EVENTS_SPACE_DEFAULT = Config('EVENTS.EVENTS_SPACE_DEFAULT').value

        self.context = {
            'view':
            'event_new_view',
            'in_space':
            request.in_space,
            'hash':
            request.hash,
            'ADMIN_URL':
            self.admin_url,
            'user':
            request.user,
            'language':
            request.language,
            'auto_search':
            request.search,
            'slug':
            '/event/new',
            'page_git_url':
            '/tree/master/_database/templates/event_new_view.html',
            'page_name':
            self.space_name + ' | New event',
            'page_description':
            'Organize an event at ' + self.space_name,
            'upcoming_events':
            Event.objects.QUERYSET__upcoming()[:4],
            'default_space':
            Space.objects.filter(str_name_en_US=EVENTS_SPACE_DEFAULT).first(),
            'all_spaces':
            Space.objects.exclude(str_name_en_US=EVENTS_SPACE_DEFAULT),
            'all_guildes':
            Guilde.objects.all(),
            'csrf_token':
            get_token(original_request)
        }
Ejemplo n.º 17
0
    def get_context(self, request):
        self.log('PhotosView.get_context()')
        from _database.models import Photo

        request = Request(request)
        self.context = {
            'view': 'photos_view',
            'in_space': request.in_space,
            'hash': request.hash,
            'ADMIN_URL': self.admin_url,
            'user': request.user,
            'language': request.language,
            'auto_search': request.search,
            'slug': '/photos',
            'page_git_url': '/tree/master/_website/templates/photos_view.html',
            'page_name': self.space_name + ' | Photos',
            'page_description':
            'Explore ' + self.space_name + '\'s history in photos!',
            'photos': Photo.objects.latest()[:30]
        }
Ejemplo n.º 18
0
    def __init__(self, request):
        from django.http import JsonResponse
        from _database.models import MeetingNote
        from _website.models import Request
        marry_messages = []
        meeting = MeetingNote.objects.current()
        running_since = meeting.running_since if meeting else None
        if Request(request).in_space:
            if running_since == '1h 30min':
                marry_messages.append(
                    'Thanks everyone for partipicating in the weekly meeting. The meeting is going on now for 1 hour and 30 minutes'
                )
            elif running_since == '2h 30min':
                marry_messages.append(
                    'I always love people actively discussion topics related to Noisebridge. However, it seems the meeting is going on now for 2 hours and 30 minutes. Please come to an end soon'
                )

        self.value = JsonResponse({
            'html': running_since,
            'marryspeak': marry_messages
        })
Ejemplo n.º 19
0
    def all_results(self, request):
        self.log('-> MeetingsView().all_results()')
        from _database.models import MeetingNote, Event
        request = Request(request)

        self.context = {
            'view': 'meetings_view',
            'in_space': request.in_space,
            'hash': request.hash,
            'ADMIN_URL': self.admin_url,
            'user': request.user,
            'language': request.language,
            'auto_search': request.search,
            'slug': '/meetings',
            'page_git_url':
            '/tree/master/_database/templates/meetings_view.html',
            'page_name': self.space_name + ' | Meetings',
            'page_description': 'Join our weekly meetings!',
            'current_meeting': MeetingNote.objects.current(),
            'next_meeting': Event.objects.QUERYSET__next_meeting(),
            'past_meetings': MeetingNote.objects.past()[:10]
        }
Ejemplo n.º 20
0
    def get_context(self, request):
        self.log('ConsensusView.get_context()')
        from _database.models import Consensus

        request = Request(request)
        self.context = {
            'view':
            'consensus_view',
            'in_space':
            request.in_space,
            'hash':
            request.hash,
            'ADMIN_URL':
            self.admin_url,
            'user':
            request.user,
            'language':
            request.language,
            'auto_search':
            request.search,
            'slug':
            '/consensus',
            'page_git_url':
            '/tree/master/_website/templates/consensus_view.html',
            'page_name':
            self.space_name + ' | Big-C consensus items',
            'page_description':
            'When you want to do something that would drastically change ' +
            self.space_name +
            ' (or need a lot of money from Noisebridge for a project) - suggest a Big-C consensus item!',
            'all_current_items':
            Consensus.objects.current(),
            'all_current_items_count':
            Consensus.objects.current().count(),
            'all_archived_items':
            Consensus.objects.archived(),
            'all_archived_items_count':
            Consensus.objects.archived().count(),
        }
Ejemplo n.º 21
0
    def get_context(self, original_request):
        self.log('LandingpageView.get_context()')
        from _database.models import Event, Photo
        from _apis.models.hackspaceOS_functions.open_status import OpenStatus

        request = Request(original_request)
        response = Response()
        self.context = {
            'view': 'landingpage_view',
            'in_space': request.in_space,
            'hash': request.hash,
            'ADMIN_URL': self.admin_url,
            'user': request.user,
            'language': request.language,
            'auto_search': request.search,
            'slug': '/',
            'page_git_url': '/tree/master/_website/templates/landingpage_view.html',
            'page_name': self.space_name,
            'page_description': response.description,
            'is_open_status': OpenStatus(original_request).value,
            'upcoming_events': Event.objects.QUERYSET__upcoming()[:5],
            'photos': Photo.objects.latest()[:33]
        }