Esempio n. 1
0
 def test_process(self):
     """
     Tests the process method for the Alarm base class.
     """
     with self.assertRaises(NotImplementedError):
         alarm = Alarm()
         alarm.process(None)
Esempio n. 2
0
File: views.py Progetto: hwijung/PM
def alarm_create_view(request):
    ajax = request.GET.has_key ( 'ajax' )
    variables = RequestContext( request, { 'username': request.user.username } )
    
    if request.method == 'POST':

        form = AlarmSaveForm ( request.POST )

        if form.is_valid():
            try:
                Alarm.save_with_form(request.user, form)
                return HttpResponseRedirect ( reverse('alarms.views.alarms_view') )

            # duplicated Title exception
            except IntegrityError as e:
                form.site.errors = 'Duplicate title.'
                return render_to_response( 'alarm_create.html',  
                                           { 'urls': PPparser.URLS.iteritems() },
                                           RequestContext( request, { 'username': request.user.username, 'error': True, 'form': form } ))
        else:
            return render_to_response( 'alarm_create.html',  
                                       { 'urls': PPparser.URLS.iteritems() },
                                         RequestContext( request, { 'username': request.user.username, 'error': True, 'form': form } ))
    elif request.GET.has_key('url'):
        url = request.GET['url']
    else:
        form = AlarmSaveForm()

    return render_to_response('alarm_create.html', { 'urls': PPparser.URLS.iteritems() }, context_instance = variables )
Esempio n. 3
0
File: views.py Progetto: hwijung/PM
def alarm_view(request, alarm_title):
    # Create Alarm from input form
    if request.method == 'POST':
        form = AlarmEditForm ( request.POST )
        if form.is_valid():
            Alarm.update(form)
            return HttpResponseRedirect ( reverse('alarms.views.alarms_view') ) 
        else:
            print form.errors
    # Delete an alarm
    elif request.method == 'DELETE':
        Alarm.delete(alarm_title)
        obj = { "result": "success" }   
        return HttpResponse( json.dumps(obj) )
    # Get Request, just show the alarms           
    else:
        alarm = Alarm.objects.get(title = alarm_title)
        form = AlarmEditForm(initial= {'title': alarm.title, 
                                       'site': alarm.site,
                                       'keyword': SearchWord.search_word_to_str(alarm.searchword_set.all()) })
        
    variables = RequestContext( request, { 'username': request.user.username, 'form': form })
    return render_to_response ( 'alarm_edit.html', variables )