Пример #1
0
def save_time_entry(request):
    
    if not logged_in(request):
        return HttpResponseRedirect('/')
    
    st = request.POST.get('start_time')
    et = request.POST.get('end_time')
    day = request.POST.get('day')
    pi = request.POST.get('pi')
    ds = request.POST.get('description')
    user = request.user

    te = TimeEntry(user_id = user.id , start_time = st, end_time = et, day = day, project_id = pi, description=ds)
    te.save()
    return HttpResponse()
def resume_activity(activities, actual_activity, actual_time_entry_start_time):
    """Resume the actual activity."""
    current_activity = get_active_window_title()
    # Check if theres was a change in the activity
    if current_activity != actual_activity:
        # Look for if the activity exists
        for previus_activity in activities:
            if previus_activity.window_title == actual_activity:
                break
        else:
            previus_activity = None

        previus_activity_time_entry = TimeEntry(
            start_time=actual_time_entry_start_time,
            end_time=datetime.now(timezone.utc))
        # If not exist the activity, it'll be created
        if not previus_activity:
            previus_activity = Activity(actual_activity)
            activities.append(previus_activity)

        # Add the time entry for the activity
        previus_activity.add_time_entry(previus_activity_time_entry)
        # Set the new actual activity
        actual_activity = current_activity
        actual_time_entry_start_time = datetime.now(timezone.utc)
    return activities, actual_activity, actual_time_entry_start_time
Пример #3
0
def dayshift_clockin_func(user_id):
  prev_entry = db.session.query(TimeEntry).filter_by(user_id=user_id, cal_date=date.today()).first()
  error = ""
  if prev_entry:
    error = "You can't clock in twice in one day"
    return error
  time_entry = TimeEntry(
      date.today(),
      datetime.now(),
      None,
      None,   
      None,
      0,
      user_id
     )
  db.session.add(time_entry)
  db.session.commit()
  success = "Added Successfully."
  return success
Пример #4
0
 def stop_timer(self, task_id):
     TimeEntry.stop_log(task_id=task_id)
     self.timer_buttons[task_id].config(
         text="Start", command=lambda: self.start_timer(task_id))
Пример #5
0
import sys

sys.path.append("../")
from models import Activity, Client, Member, Project, TimeEntry, IndicatorConsolidation

if __name__ == "__main__":
    Member.save_from_clockify()
    Client.save_from_clockify()
    Project.save_from_clockify(archived="")
    Activity.save_from_clockify()
    TimeEntry.save_from_clockify(start="2020-02-23T00:00:01Z")
    IndicatorConsolidation.populate_prep(start="2020-02-23T00:00:01")
Пример #6
0
 def stop_timer(self, task_id):
     TimeEntry.stop_log(task_id=task_id)
     self.timer_buttons[task_id].config(text="Start", command=lambda: self.start_timer(task_id))
Пример #7
0
    def __init__(self, master, no_gui):
        tk.Frame.__init__(self, master)
        log.info("Initiating Application...")

        master.protocol("WM_DELETE_WINDOW", self.destroy_gui)

        # check if a data folder exists
        if not os.path.exists("data"):
            log.info("data dir not found, creating...")
            os.mkdir("data")

        # TODO: make more things that you can configure (theme for example)
        default_config = {"mouse_timeout": 10}

        # check if a data/config file exists
        if not os.path.isfile("data/config.json"):
            log.info("config file not found, creating...")
            with open("data/config.json", "w") as f:
                json.dump(default_config, f, indent=4, sort_keys=True)
                self.config = default_config

        else:
            log.info("Opening config file...")
            with open("data/config.json", "r") as f:
                self.config = json.load(f)

        log.info("Loading programs from db...")
        self.load_programs()

        log.info("Deleting unfinished time entries...")
        TimeEntry.delete_unfinished_entries()
        log.info("Starting activity loop...")

        # create a queue for running functions in the main thread from
        # other threads
        self.request_queue = queue.Queue()
        self.result_queue = queue.Queue()

        # start the queue loop
        self.queue_loop()

        # create the activity loop thread and start it
        self.activity_thread = threading.Thread(target=self.activity_loop)
        self.activity_thread.daemon = True  # close the thread when the app is destroyed
        self.activity_thread.start()

        # create the multiprocess listener
        partial = functools.partial(self.submit_to_queue, self.start_gui)
        self.multiprocess_listener = threading.Thread(
            target=utils.multiprocess_listener, args=(partial, ))
        self.multiprocess_listener.daemon = True  # close the thread when the app is destroyed
        self.multiprocess_listener.start()

        # create the updater loop that runs every 24 hours
        # double partial because we need to submit a function to the queue.
        # both have params
        partial = functools.partial(updater.perform_update, master)
        callback = functools.partial(self.submit_to_queue, partial)
        self.updater_thread = threading.Thread(target=utils.loop,
                                               args=(86400, callback))
        self.updater_thread.daemon = True  # close the thread when the app is destroyed
        self.updater_thread.start()

        self.main_display = None

        if not no_gui:
            self.start_gui()
Пример #8
0
 def stop_logging_program(self, program):
     """Stop logging a program to the db"""
     TimeEntry.stop_logging(program.id)
Пример #9
0
from views import db
from models import TimeEntry, User
from datetime import datetime, date

db.create_all()

mnorman = User(name='mnorman',
               email='*****@*****.**',
               temp_pass=None,
               role='user')
mnorman.hash_password('aaaaaa')
tom = User(name='tom', email='*****@*****.**', temp_pass=None, role='user')
tom.hash_password('aaaaaa')
jdoe = User(name='jdoe', email='*****@*****.**', temp_pass=None, role='user')
jdoe.hash_password('aaaaaa')
mike = User(name='Mike',
            email='*****@*****.**',
            temp_pass=None,
            role='admin')
mike.hash_password('aaaaaa')
db.session.add(TimeEntry(date.today(), datetime.now(), None, None, None, 0, 1))
db.session.add(mnorman)
db.session.add(jdoe)
db.session.add(tom)
db.session.add(mike)

db.session.commit()