Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Salesforce scheduling issues #4387

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions seed/static/seed/partials/organization_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ <h2><i class="fa-solid fa-clock"></i> {$:: 'Scheduled Daily Update' | translate
<label class="col-sm-2 col-sm-offset-1 control-label" for="update_at_hour" translate>Hour</label>
<div class="col-sm-5">
<p><span translate="SF_UPDATE_HOUR_TEXT"></span> Timezone: {$ timezone $}</p>
<input type="text" class="form-control" id="update_at_hour" ng-model="conf.update_at_hour" ng-disabled="::!auth.requires_owner" />
<input type="number" class="form-control" id="update_at_hour" ng-model="conf.update_at_hour" ng-disabled="::!auth.requires_owner" min="0" max="23" />
</div>
</div>
</form>
Expand All @@ -420,7 +420,7 @@ <h2><i class="fa-solid fa-clock"></i> {$:: 'Scheduled Daily Update' | translate
<label class="col-sm-2 col-sm-offset-1 control-label" for="update_at_minute" translate>Minute</label>
<div class="col-sm-5">
<p translate="SF_UPDATE_MINUTE_TEXT"></p>
<input type="text" class="form-control" id="update_at_minute" ng-model="conf.update_at_minute" ng-disabled="::!auth.requires_owner" />
<input type="number" class="form-control" id="update_at_minute" ng-model="conf.update_at_minute" ng-disabled="::!auth.requires_owner" min="0" max="59" />
</div>
</div>
</form>
Expand Down
5 changes: 4 additions & 1 deletion seed/utils/salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def schedule_sync(data, org_id):

timezone = data.get('timezone', get_current_timezone())

if 'update_at_hour' in data and data['update_at_hour'] and 'update_at_minute' in data and data['update_at_minute']:
if 'update_at_hour' in data and 'update_at_minute' in data:
# create crontab schedule
schedule, _ = CrontabSchedule.objects.get_or_create(
minute=data['update_at_minute'],
Expand All @@ -78,6 +78,9 @@ def schedule_sync(data, org_id):
task.crontab = schedule
task.save()

# Cleanup orphaned/unused crontab schedules
CrontabSchedule.objects.exclude(id__in=PeriodicTask.objects.values_list('crontab_id', flat=True)).delete()


def toggle_salesforce_sync(salesforce_enabled, org_id):
""" when salesforce_enabled value is toggled, also toggle the auto sync
Expand Down
2 changes: 1 addition & 1 deletion seed/views/v3/salesforce_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def update(self, request, pk):
}, status=status.HTTP_200_OK)
except django.core.exceptions.ValidationError as e:
message_dict = e.message_dict
# rename key __all__ to general to make it more user friendly
# rename key __all__ to general to make it more user-friendly
if '__all__' in message_dict:
message_dict['general'] = message_dict.pop('__all__')

Expand Down